[Qt-interest] QTreeView and custom QAbstractItemModel performance problem

Sean Harmer sean.harmer at maps-technology.com
Thu Jul 8 11:45:26 CEST 2010


Hi,

On 08/07/2010 09:58, Andreas Pakulat wrote:
> Can you post your model implementation? It sure sounds like you're doing
> the appending wrong, but without having a look at the code its not possible
> to say what exactly is wrong.
>
> A blind guess could be that you're reset'ting you're model every time you
> add a row instead of using begin/endInsertRows correctly. See the example
> models in Qt.
>
> Also I'd suggest to use a QTableView instead of QTreeView as that one is
> significantly faster on non-tree structures (you can tweak it to have no
> lines etc.) in case you ever get more than 100 rows.

What Andreas says is all true. However if you are using QTreeView a good 
optimisation to use is to tell the view that all rows are the same 
height. With this information the view does nto have to query every row 
of the model to calculate the total height of the viewport for scrollbar 
calculations. See:

http://doc.qt.nokia.com/4.7-snapshot/qtreeview.html#uniformRowHeights-prop

Sean



More information about the Qt-interest-old mailing list