Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    4
    8
    234
    Loading More Posts
    • 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
      keyboard_hellchang last edited by

      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!

      JonB 1 Reply Last reply Reply Quote 0
      • dheerendra
        dheerendra Qt Champions 2022 last edited by

        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 Reply Quote 1
        • K
          keyboard_hellchang @dheerendra last edited by

          @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.Hilk 1 Reply Last reply Reply Quote 0
          • J.Hilk
            J.Hilk Moderators @keyboard_hellchang last edited by

            @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

            Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

            K 1 Reply Last reply Reply Quote 3
            • JonB
              JonB @keyboard_hellchang last edited by

              @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 Reply Quote 0
              • K
                keyboard_hellchang @dheerendra last edited by

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

                1 Reply Last reply Reply Quote 0
                • K
                  keyboard_hellchang @J.Hilk last edited by

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

                  1 Reply Last reply Reply Quote 1
                  • K
                    keyboard_hellchang @JonB last edited by

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

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post