Results 1 to 4 of 4

Thread: Listview inside Listview inside Treeview

  1. #1
    Join Date
    Apr 2017
    Posts
    2
    Thanks
    2
    Qt products
    Platforms
    Windows

    Default Listview inside Listview inside Treeview

    Hello,

    I would like to build an app to make it easier to compare estimates of cost. Each company has one column and the column is split into groups. Each group consist of a list of cost centres (Mainlist). Each Company contributes with an variable amount of items to one cost centre (Sublist).

    I tried to find an solution but as of now I am not shure if this is possible at all.
    Any Help appreciated.

    compare.jpg

  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: Listview inside Listview inside Treeview

    QAbstractItemModel is flexible enough to build such a tree, since it permits each column in a row to have multiple children (rows). However, there is no standard Qt class derived from QAbstractItemView that can display such a structure. QTreeView supports only trees where the first column in a row has children.

    An alternative to this would be to design your UI in such as way as to split it into top level and detail views, where, for example, the top level view is a tree view that shows only the MainList items as children for each tree row. Clicking on a MainList item loads the sublists into a table view, where each part of the sublist is column in a row in the table.

    If you really need the UI to look like your mockup, then you have to write it yourself.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    Tomundo (10th April 2017)

  4. #3
    Join Date
    Apr 2017
    Posts
    2
    Thanks
    2
    Qt products
    Platforms
    Windows

    Default Re: Listview inside Listview inside Treeview

    Your suggestion is totally ok and i am allready implementing it. Now I am at the point where i want to draw the sublists. Currect me if i am wrong. I plan to reimplement the drawRow method of QTreeView and draw my sublists manually.

  5. #4
    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: Listview inside Listview inside Treeview

    I plan to reimplement the drawRow method of QTreeView and draw my sublists manually.
    You'll probably need more than that, and I don't even know if you can derive from QTreeView and have it work correctly. As far as I know, the tree view doesn't consider children of anything other than the first column in any row of the model. You would have to look at the drawTree() protected method to see how it is implemented. Unfortunately, it isn't virtual so it can't be overridden in that way.

    You'll most likely also have to look into the tree layout and sizing methods that report the heights and widths of rows and probably override them too.

    Some poking around in the qinclude archive might turn up something useful.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  6. The following user says thank you to d_stranz for this useful post:

    Tomundo (3rd September 2017)

Similar Threads

  1. ComboBox Model inside Listview
    By Binary01 in forum Qt Quick
    Replies: 11
    Last Post: 24th October 2016, 11:36
  2. Listview inside repeater - model
    By Qmyo in forum Qt Quick
    Replies: 1
    Last Post: 17th May 2016, 16:24
  3. Replies: 2
    Last Post: 16th May 2016, 23:50
  4. ListView inside another element
    By Dp0H in forum Qt Quick
    Replies: 0
    Last Post: 24th September 2012, 12:44
  5. Tableview - Three subcolumns inside one column?
    By qlands in forum Qt Programming
    Replies: 2
    Last Post: 24th March 2010, 15:04

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.