4

I developed a Qt tree with 1,000,000 items under a node. The code is similar to its simple tree model example at http://qt-project.org/doc/qt-5.0/qtwidgets/itemviews-simpletreemodel.html .

When I click key "End", it takes 15 seconds to go to the last item. Any way to make it faster?

user1899020
  • 13,167
  • 21
  • 79
  • 154
  • 5
    Have you already set [uniformRowHeights](http://qt-project.org/doc/qt-4.8/qtreeview.html#uniformRowHeights-prop)? –  Jan 13 '13 at 17:56
  • 2
    After setting it true, it takes almost no time to navigate the items. Thanks so much! – user1899020 Jan 13 '13 at 23:07
  • If you need 1,000,000 items in your tree, you really should rethink your user-interface design. – GogglesGuy Feb 08 '13 at 21:01
  • I respectfully disagree. When you add a million items to a tree and notice it's very slow, the first thing you should ask is whether it even makes sense to display that many items, not how to make it faster. – GogglesGuy Feb 08 '13 at 21:37
  • 1
    Sorry, but a million-item collection is by no measure that makes sense to computers "huge", even if it seems like a big number to humans. In Python(!), creating the list of integers from `0` to `1000000` is a nearly instantaneous operation. While I agree presenting that number of items in a GUI presents a nontrivial usability problem, this is a tangential concern. Those belong into comments as speculation whether this question manifests the XY problem. However, it's not unreasonable to want the GUI to not grind down to a halt on what's a modest dataset. – millimoose Feb 08 '13 at 22:00
  • 1
    The link that you posted above is now a dead link. Did you mean [this link](http://qt-project.org/doc/qt-4.8/itemviews-simpletreemodel.html)? – stackunderflow Mar 08 '13 at 20:12
  • @Roku Maybe write that comment as answer so this question can become solved... user1899020 if Roku does not write it as answer, you can do that and accept it a few days later. – hyde Mar 13 '13 at 21:05

1 Answers1

4

Set uniformRowHeights to true. Then the row height is calculated only once, instead of million times, making the QTreeView much faster.