PDA

View Full Version : QTreeView Fixed column & QTableView



jpujolf
1st August 2008, 08:16
Some time ago ormonde asked how to fix first column in a QTreeView. And jpn & wysota answered him that could be achieved placing two separate views one next to the other.

http://www.qtcentre.org/forum/f-qt-programming-2/t-fixed-column-in-qtreeview-13529.html

I want to apply this solution, it seems easy and effective, but I want to improve it a little bit, It's possible ?

I'm working usually with a very large amount of rows ( 50.000 or more ) and a lot of columns too ( 20-50 ). So, I've to manage a lot of data ( 1M to 2.5M different values ). QTreeView is VERY, VERY slow ( in opposition to QTableView , I used before ).

By now, when I press Page Down, it takes 3-5 seconds to move to the end with 6-7K rows. It's a little bit time expensive.

I've made some tests and reducing the number of columns in a treeview, reduces too the time to move from end to end, so I've thought that i can place a Qtreeview on the left & a QTableview on the right, making it scrollable for data. The problem is : how can I sincronize indexes & selection moves between views ?

caduel
1st August 2008, 09:12
Set the selectionModel of the second view to that of the first (see QAbstractItemView::setSelectionModel()).

The slowness of the treeview might be improved by setting QTreeView::setUniformRowHeights() to true.

HTH

jpujolf
1st August 2008, 09:34
You did it !! Setting uniformRowheights improves speed a lot !! I've presumed that that option was the default. I was wrong...

Or at least it MUST be the default :confused:

Thanks a lot !!

jpn
1st August 2008, 15:55
Setting uniformRowheights improves speed a lot !! I've presumed that that option was the default. I was wrong...

Or at least it MUST be the default :confused:
It cannot be the default value because it would break lists which don't happen to have uniform row heights. Having uniform row heights is a common, but still special case. Special cases can be used as optimizations but not as defaults. I guess somebody skipped the "Improving Performance" section in QTreeView while starting to use the class. ;)

jpujolf
13th August 2008, 10:35
I guess somebody skipped the "Improving Performance" section in QTreeView while starting to use the class. ;)

Oh dear !! I think I've to stop making diagonal-reads of documentation... :p