Results 1 to 2 of 2

Thread: Custom ListModel and QML

  1. #1
    Join Date
    Jan 2007
    Posts
    177
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 10 Times in 9 Posts

    Default Custom ListModel and QML

    Hi,

    i want to have a qml list managed by a custom list model (because the qml listmodel is just for static data?).
    The list items should be more than just items painted to a view, i need to have buttons and other elements displayed and connected to other objects, instanciated in c++.

    So in the Model i have to create a c++ object that handles the functionality and create a qml object that handles the view (as list item) and bind them to each other using signals and slots.

    Is it possible to do something like that or is there an easier way? The processes that should be connected to the gui elements of each list item are provided by c++ classes that i would rather not implement newly in javascript/qml.

    The effort should be minimal cause it's just a gui remake.

    Cheers,
    Kernel

  2. #2
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android
    Thanks
    7
    Thanked 20 Times in 20 Posts

    Default Re: Custom ListModel and QML

    Models are containers for data and their roles. Nothing more. Data from the list items populating the model are typically wrapped in a QML delegate. If a delegate has a MouseArea element, for example, then the corresponding onClicked functionality is defined there, even if it consists of nothing more than propagating the clicked signal for handling elsewhere, i.e. in another element of the delegate, in a view, or even in C++ code.

    As for communication between QML and C++, make sure you read this thoroughly.

Similar Threads

  1. Replies: 1
    Last Post: 6th August 2012, 16:48
  2. QML ListModel for interaction with C++
    By shock in forum Qt Quick
    Replies: 23
    Last Post: 21st March 2012, 23:42
  3. Replies: 6
    Last Post: 12th March 2012, 10:06
  4. ListModel.remove() crashes program
    By truefusion in forum Qt Quick
    Replies: 5
    Last Post: 5th February 2012, 15:27
  5. A simplest ListModel... no example :(
    By tomek in forum Newbie
    Replies: 5
    Last Post: 7th January 2006, 00:32

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.