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. How to refresh data on horizontal header of QTableWidget?
Qt 6.11 is out! See what's new in the release blog

How to refresh data on horizontal header of QTableWidget?

Scheduled Pinned Locked Moved Solved General and Desktop
28 Posts 4 Posters 5.4k Views 2 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #19

    @tovax said in How to refresh data on horizontal header of QTableWidget?:

    The resize mode is QHeaderView::Stretch

    Ok, this is at least not a problem for the update. So please provide a small testcase.

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

    tovaxT 2 Replies Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      @tovax said in How to refresh data on horizontal header of QTableWidget?:

      The resize mode is QHeaderView::Stretch

      Ok, this is at least not a problem for the update. So please provide a small testcase.

      tovaxT Offline
      tovaxT Offline
      tovax
      wrote on last edited by
      #20
      This post is deleted!
      1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @tovax said in How to refresh data on horizontal header of QTableWidget?:

        The resize mode is QHeaderView::Stretch

        Ok, this is at least not a problem for the update. So please provide a small testcase.

        tovaxT Offline
        tovaxT Offline
        tovax
        wrote on last edited by tovax
        #21

        @Christian-Ehrlicher
        Here is the github link:
        TableView
        Best Regards!

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

          @tovax: I'll give it a try today, thx

          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
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #23

            Looks like the culprit is that a header data change triggers a complete repaint through QAbstractItemView::updateGeometries() which is very expensive. It doesn't matter if you call headerDataChanged() once per section or completely - it's a delayed trigger.

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

            tovaxT 1 Reply Last reply
            2
            • Christian EhrlicherC Christian Ehrlicher

              Looks like the culprit is that a header data change triggers a complete repaint through QAbstractItemView::updateGeometries() which is very expensive. It doesn't matter if you call headerDataChanged() once per section or completely - it's a delayed trigger.

              tovaxT Offline
              tovaxT Offline
              tovax
              wrote on last edited by
              #24

              @Christian-Ehrlicher
              Hi,
              In other words, can't I update the data on the horizontal header, please?
              Best Regards!

              mrjjM 1 Reply Last reply
              0
              • tovaxT tovax

                @Christian-Ehrlicher
                Hi,
                In other words, can't I update the data on the horizontal header, please?
                Best Regards!

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #25

                @tovax
                Hi
                Nope, not as fast as you wish.
                On my (albeit old) gamer pc, it uses 28% CPU to refresh it.
                So for less powerful system, you will have to find another way to do the same
                than using the headers. Its too expensive to be used in this way.
                ( even 'just' 10 times pr second )

                So basically its not a supported use case with Qt to have high-speed header refresh. That said you might be able to fix it with a custom HeaderView
                but if there is enough virtual function to override this behavior, i cannot say currently.

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

                  Or, as we said already more times - don't try to update at 100Hz - noone can ever read this...

                  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
                  • tovaxT Offline
                    tovaxT Offline
                    tovax
                    wrote on last edited by
                    #27

                    OK, Thanks for both of you! I'll think about other ways.
                    Best Regards!

                    1 Reply Last reply
                    0
                    • tovaxT Offline
                      tovaxT Offline
                      tovax
                      wrote on last edited by
                      #28

                      Solved:

                      1. Derived from QAbstractTableModel + QTableView
                      2. Create two QTableView, one for cell's data, another for header data.
                      3. Frozen the first row of the QTableView used for header data, and refresh data in it (100Hz).
                      4. (Refer to official demo: Frozen Column Example)
                      1 Reply Last reply
                      1

                      • Login

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