Results 1 to 20 of 54

Thread: Integration: Nested Tree Parent Child C++ Classes with Models/Delegates for QML

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Integration: Nested Tree Parent Child C++ Classes with Models/Delegates for QML

    There are multiple options for this.

    1) You could have an internal data structure and have a model that presents the album "view" on the data and models that present the card "view" of the data.
    Depending on whether you can show multiple albums at the same time, you might need more than one instance of the latter.

    2) Another option is to make some of the data classes themselves into models themselves, e.g. the "Album" class and the "App" class.

    3) The "App" class could also be just a normal QObject derived class and have the "Album" models as a list property.

    Option (1) requires separate classes for data and models, but also allows the data classes to be copyable.
    I.e. more classes and thus more core, but treating data separately from the QML adapter to the data.

    Options (2) and (3) need at least the "Album" class as a QAbstractListModel subclass, so a QList<Album*> as the container in "App".

    When you write "all classes inherit QAbstractListModel" it looks like your chosen approach is (2), but do you also mean "Card" is a list model?

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    Nizars (30th December 2016)

Similar Threads

  1. Nested Models
    By Dan7 in forum Qt Programming
    Replies: 1
    Last Post: 26th August 2015, 20:31
  2. Models and Delegates
    By bgeller in forum Newbie
    Replies: 13
    Last Post: 4th March 2010, 04:46
  3. QStandardItemModel, parent / child to form tree structure
    By Nightfox in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2010, 17:01
  4. Nested delegates in a QListWidget
    By youkai in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2009, 08:48
  5. Models, delegates or views and how?
    By maddogg in forum Newbie
    Replies: 3
    Last Post: 9th November 2007, 13:59

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.