Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Slow adding of QTreeWidgetItems inside a tab, if another tab opened
Forum Updated to NodeBB v4.3 + New Features

Slow adding of QTreeWidgetItems inside a tab, if another tab opened

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 540 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rebus_x
    wrote on last edited by rebus_x
    #1

    Hi.
    In my application, I have a QTabWidget with 2 tabs. One contains a QTreeWidget and I do nothing in it. Second contains another QTreeWidget and a QTableWidget, and they are filled with data when reading a file. (10s of thousands of items in tree widget, thousands in table widget.)

    The problem is, when I have 1st tab opened and read the file, the loading takes roughly 20 seconds, and if I open 2nd tab before reading file - it takes 1 second or less. I used QElapsedTimer for measuring, and saw that in 1st case addChild() & addTopLevelItem() in tree widget start to work slower over time, and same goes for setVerticalHeaderItem() in table widget. No such problem when the 2nd tab is opened before reading.

    What could be the reason for this?
    I tried this, but nothing changed:

    • setUpdatesEnabled(false) for tree widget (in tab 2)
    • setVisible(false) for tree widget (in tab 2)
    • blockSignals() for tree widget (in tab 2) //edit: close, but not enough, see my next post
    • setUpdatesEnabled(false) for tab widget
    • setUpdatesEnabled(false) for the window

    Also, Qt 5.13.1, Windows 7 x64 SP1.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      As long as no code we can't say much but one thing: The QTreeWidget + QTreeWidgetItem is just a convenience class. If you've a lot of data create your own model.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • R Offline
        R Offline
        rebus_x
        wrote on last edited by rebus_x
        #3

        Here is what helped. Did this before data loading:

        treewidget->blockSignals(true);
        treewidget->model->blockSignals(true);
        

        The person who posted this solution (here) had very similar problem with items in QTableWidget. Must have something to do with the way these items are created.

        Also in my case, could have been related to "visible" property of a widget, because problem also occured when my widgets were explicitly hidden.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved