PDA

View Full Version : Listview inside Listview inside Treeview



Tomundo
6th April 2017, 22:07
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.

12434

d_stranz
6th April 2017, 23:42
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.

Tomundo
10th April 2017, 23:11
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.

d_stranz
11th April 2017, 01:47
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 (http://inqlude.org/) archive might turn up something useful.