PDA

View Full Version : Two Trees in one View



kemp
26th January 2009, 21:08
Hello!

I am having trouble with implementing a view with two trees beside one another.Each tree should have more than one column. The trees are separated byone column. This columns purpose is to display compare symbols.So two trees that can be compared in one view.

Here is a sample picture.

http://f.imagehost.org/0778/tree_example.png


What would be the best approach for this problem?

Thank you for your answers.

caduel
26th January 2009, 21:29
One way is to place two QTreeViews besides each other:
keep the expanded items in sync (if you want)
keep the scroll positions synced
You need to connect to QTreeView::collapsed() / expanded; and
probably need to subclass QTreeView to override QAbstractScrollArea::scrollContentsBy() (in order to keep both views at the same y coordinate).

HTH

kemp
26th January 2009, 22:09
Thank you for your answer.I also thought about that but the problem is that i need to have joust one view.

zatoichi
26th January 2009, 23:15
Maybe you could try making your own model which will be mapping data from second treeview to indices begining from third column. I guess it'll solve scrolling and expanding problem.

wysota
27th January 2009, 00:15
Thank you for your answer.I also thought about that but the problem is that i need to have joust one view.

QTreeView doesn't support two independent sets of columns and two independent sets of rows which is what you want. So either you will use two trees and make them look like one (which is possible) or you'll have to implement your own view based on QAbstractItemView.

kemp
27th January 2009, 10:31
Thank you for your answer. I will try.

jpn
27th January 2009, 16:00
the problem is that i need to have joust one view.
Just curious, where does such requirement come from? :)