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. The speed is greatly reduced when you spray a lot of data on QTableWidget. Help!

The speed is greatly reduced when you spray a lot of data on QTableWidget. Help!

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 554 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.
  • K Offline
    K Offline
    keyboard_hellchang
    wrote on last edited by
    #1

    The qt version is 4.8.7
    OS is Centos7.

    I attempted to insert more than 100,000 integer data into QTableWidget. However, UI was not allowed because the rate at which data was filled in the cell was greatly reduced.
    It is currently designed to fill data with a double repeat statement(for).
    Help me with any ideas!

    JonBJ 1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      May be your application is single threaded. Since you are inserting large set of data, UI is not able to refresh. May be you can insert rows (30 or so) in batches. Where are you fetching the data ? Are you doing the fetch & insert at same time ? If yes, see if you can split the fetch & insert into UI, make it concurrently.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      K 2 Replies Last reply
      1
      • dheerendraD dheerendra

        May be your application is single threaded. Since you are inserting large set of data, UI is not able to refresh. May be you can insert rows (30 or so) in batches. Where are you fetching the data ? Are you doing the fetch & insert at same time ? If yes, see if you can split the fetch & insert into UI, make it concurrently.

        K Offline
        K Offline
        keyboard_hellchang
        wrote on last edited by
        #3

        @dheerendra

        There are four different QTableWidgets and four different integer vectors (element: 100,000).

        One integer vector per table (element: 100,000) is inserted in turn.

        When we experimented, it took too long to insert one integer vector (element: 100,000) into a single table.

        The integer vector is pre-created before filling the table.

        After the integer vector is finished, it begins to fill the table.

        J.HilkJ 1 Reply Last reply
        0
        • K keyboard_hellchang

          @dheerendra

          There are four different QTableWidgets and four different integer vectors (element: 100,000).

          One integer vector per table (element: 100,000) is inserted in turn.

          When we experimented, it took too long to insert one integer vector (element: 100,000) into a single table.

          The integer vector is pre-created before filling the table.

          After the integer vector is finished, it begins to fill the table.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @keyboard_hellchang you should use a proper model for your view and implement
          canFetchMore and fetchMore for dynamic loading of the data, your view will not need to display 100000 items at once

          take this example from the documentation as a guide
          https://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          K 1 Reply Last reply
          3
          • K keyboard_hellchang

            The qt version is 4.8.7
            OS is Centos7.

            I attempted to insert more than 100,000 integer data into QTableWidget. However, UI was not allowed because the rate at which data was filled in the cell was greatly reduced.
            It is currently designed to fill data with a double repeat statement(for).
            Help me with any ideas!

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @keyboard_hellchang said in The speed is greatly reduced when you spray a lot of data on QTableWidget. Help!:

            I attempted to insert more than 100,000 integer data into QTableWidget.

            Maybe this is not a suitable number of items for a generic QTableWidget?! If I assume you have, say, 20 columns, that would be 5,000 rows. That's an awful lot for a user to look/scroll through!

            As @J-Hilk has said, use a proper model for this much data, and do some dynamic fetching/paging when the user needs to scroll.

            K 1 Reply Last reply
            0
            • dheerendraD dheerendra

              May be your application is single threaded. Since you are inserting large set of data, UI is not able to refresh. May be you can insert rows (30 or so) in batches. Where are you fetching the data ? Are you doing the fetch & insert at same time ? If yes, see if you can split the fetch & insert into UI, make it concurrently.

              K Offline
              K Offline
              keyboard_hellchang
              wrote on last edited by
              #6

              @dheerendra
              QAbstractTableModel has been used to solve this problem! Thank you!

              1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @keyboard_hellchang you should use a proper model for your view and implement
                canFetchMore and fetchMore for dynamic loading of the data, your view will not need to display 100000 items at once

                take this example from the documentation as a guide
                https://doc.qt.io/qt-5/qtwidgets-itemviews-fetchmore-example.html

                K Offline
                K Offline
                keyboard_hellchang
                wrote on last edited by
                #7

                @J-Hilk
                QAbstractTableModel has been used to solve this problem! Thank you!

                1 Reply Last reply
                1
                • JonBJ JonB

                  @keyboard_hellchang said in The speed is greatly reduced when you spray a lot of data on QTableWidget. Help!:

                  I attempted to insert more than 100,000 integer data into QTableWidget.

                  Maybe this is not a suitable number of items for a generic QTableWidget?! If I assume you have, say, 20 columns, that would be 5,000 rows. That's an awful lot for a user to look/scroll through!

                  As @J-Hilk has said, use a proper model for this much data, and do some dynamic fetching/paging when the user needs to scroll.

                  K Offline
                  K Offline
                  keyboard_hellchang
                  wrote on last edited by
                  #8

                  @JonB
                  QAbstractTableModel has been used to solve this problem! Thank you!

                  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