Results 1 to 2 of 2

Thread: Nested Models

  1. #1
    Join Date
    Aug 2015
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Nested Models

    Hi everyone,
    I'm using Qt4.8 and I need to make a model like the one in the attached picture: two parents, for both parent there is a set of childs with an associated table.

    What I'd like to know is: it's possible to make it with a single model? If the answer is "Yes" how can I proceed? (link/tutorials are welcome)
    Is there an alternative way to follow? for example: two treemodels, the first one for parent-child structure the second with tables, in which
    all childs are linked to their table through a QMap

    Last edited by Dan7; 26th August 2015 at 20:08.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Nested Models

    Yes, it is possible with QAbstractItemModel-based model. For each level in your model, you will need to return the appropriate values for rowCount() (number of child rows for a given item) and columnCount() (number of cells in the child row). You will also need to pay close attention to the parent / child relationships when you implement these methods as well as data() / setData() and index().

    Sorry, but I don't know of any examples, nor is there an out-of-the-box QAbstractItemView-derived class that can display such a model.

Similar Threads

  1. Replies: 15
    Last Post: 24th November 2014, 14:48
  2. Questions about models
    By xtal256 in forum Qt Programming
    Replies: 15
    Last Post: 16th August 2011, 03:37
  3. Editable Models
    By MTK358 in forum Newbie
    Replies: 1
    Last Post: 9th September 2010, 20:58
  4. sql models
    By damiano19902 in forum Newbie
    Replies: 1
    Last Post: 4th June 2009, 08:18
  5. Proxy models and slection models
    By amunitz in forum The Model-View Framework
    Replies: 1
    Last Post: 23rd September 2008, 15:35

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.