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. Fastest way to select qtreeview items programatically...
QtWS25 Last Chance

Fastest way to select qtreeview items programatically...

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 444 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    Hey

    I sweat I was asking for it before but I cant find topic... in any case... is this the fastest way ?

                    QItemSelection sel;        
                    QVector<QItemSelection>selList(items.size());
                    for (int x = 0; x < items.size(); ++x) {
                        selList[x]= QItemSelection(items[x], items[x]);
                    }
                    for (int x = 0; x < items.size(); ++x) {
                        sel.merge(selList[x], QItemSelectionModel::Select);
                    }
                    mSelectionRangeOld = selectionModel()->selection();
                    if (cSel) {
                        selectionModel()->clearSelection();
                    }
                    if (extend) {
                        selectionModel()->select(sel, QItemSelectionModel::Select | QItemSelectionModel::Rows);
                    } else {
                        selectionModel()->select(sel, QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
                    }
    

    Can any part of it be done in thread? I'm worried with 20-30k rows & 10 columns could be slow... like very slow...

    TIA

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Out of curiosity, why do you need to select that much elements programmatically ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Out of curiosity, why do you need to select that much elements programmatically ?

        D Offline
        D Offline
        Dariusz
        wrote on last edited by
        #3

        @SGaist 3D app, say user selects 50k meshes, I need to reflect that in tree view :- )

        1 Reply Last reply
        0
        • T Offline
          T Offline
          Taytoo
          wrote on last edited by Taytoo
          #4

          Never tried selecting 50K items before. But if they happen in a single method call/forloop, it'll likely be much faster if you:

          1. Stop UI updates by calling qtreeview->setUpdatesEnabled(false) at the beginning and qtreeview->setUpdatesEnabled(true) at the end.
          2. Stop item related signals from being generated by calling qtreeview->blockSignals(true) at the beginning and qtreeview->blockSignals(false) at the end.

          Once this is done, then the only cpu usage would be qtreeview model being updated and final UI update at the end.

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

            Why would someone see 50k meshes in a tree view? What should the user do with this information...

            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
            0

            • Login

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