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. Hiding rows in QTableView seems to be slow
Forum Updated to NodeBB v4.3 + New Features

Hiding rows in QTableView seems to be slow

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 10.3k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    stoeltze
    wrote on last edited by
    #1

    Hi,

    I am using QTableView for handling a table with up to 600,000 rows. Displaying the table and sorting it works well.
    However, in my interactive environment, I need to rapidly hide/show rows depending on the row index. For a smaller
    number of rows (~3000) this works perfectly fast but for 600,000 rows it is terribly slow. As a solution, I tried:
    @
    qtableview->setUpdatesEnabled(false);
    <showRow(...)/hide row(...)>
    qtableview->setUpdatesEnabled(true);
    @
    However, this didn't help.

    Any other idea is deeply appreciated.

    Best Regards,
    Steffen

    Edit: Please use @ tags to highlight code; Andre

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Have a look at Qsortfilterproxymodel.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stoeltze
        wrote on last edited by
        #3

        Thank you very much for the quick reply. I had a look at Qsortfilterproxymodel. I understand now how to use regular expressions to filter rows with respect to the contents of (a) specific field(s). However, I want to filter the rows with respect to their index which is not stored in any field. It just exists implicitly. For example, hide rows 1-5, 10-100, and 500-2000 and show the rest. Could you please provide a hint on how to use Qsortfilterproxymodel for that purpose.

        Thank you very much.
        Steffen

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on last edited by
          #4

          Have a look at "filterAcceptsRow()":http://doc.qt.nokia.com/4.7/qsortfilterproxymodel.html#filterAcceptsRow

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #5

            Your index is just a column in your table ,you should be able to filter on using filteracceptsrow.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • S Offline
              S Offline
              stoeltze
              wrote on last edited by
              #6

              Thanks for the helpful suggestions. I guess, I derive my own class from Qsortfilterproxymodel. Then, I overwrite the method filteracceptsrow. In my method, I check whether "int source_row" shall be shown or hidden based on a boolean array (size = number of rows) I already have and I return true or false, respectively. Once the boolean array in my interactive application changes, I have to call invalidateFilter() on my QSortFilterProxyModel. Am I right?

              Steffen

              1 Reply Last reply
              0
              • L Offline
                L Offline
                loladiro
                wrote on last edited by
                #7

                Yes, you are.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  stoeltze
                  wrote on last edited by
                  #8

                  The procedure I described above works very well. Thanks a lot to Eddy and loladiro. Just one thing I would like to add is that instead of calling "invalidateFilter()" on the custom QSortFilterProxyModel, one should call "invalidate()" which is considerably faster. I don't know why...

                  Steffen

                  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