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. Programmatically force redraw of QHeaderView
Forum Updated to NodeBB v4.3 + New Features

Programmatically force redraw of QHeaderView

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

    I would try to mimic the behavior of the patch by catching QEvent::Resize and then doing something so d->invalidateCachedSizeHint(); is callled. You could call this directly but then you need to use private headers which should be avoided... maybe by calling dataChanged() with invalid indexes (it calls invalidateCachedSizeHint() without checking the indexes).

    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
    • M Offline
      M Offline
      marcbf
      wrote on last edited by
      #12

      Dumb question: Should I call dataChanged() on the frozen header or on the view that contains the frozen header? I'm asking because the former doesn't seem to work (as everything else I've tried so far).

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

        On the headerView which you wanted to resize. Maybe you should first play around with the testcase in the bugreport to find a solution there - so we have a common base and a minimal testcase.

        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
        • M Offline
          M Offline
          marcbf
          wrote on last edited by
          #14

          Sorry for taking so long to update this. I had to do some changes to the code from the bug, so it would work with Qt 5.4.1. Also, I needed to change it so I could add one line at a time to the view. Well, and regular work. ;-)

          I wanted to upload the code, but apparently I do not have enough privileges.

          Well, to make it short, everything works in the test case. Now I just need to figure out why that is and why my (substantially larger) version doesn't. I'll keep this thread updated with my findings.

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

            At least good to hear that the testcase works :)
            Uploading to the bug is only possible for bug-owners. You have to upload it here in the forum.

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

            M 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              At least good to hear that the testcase works :)
              Uploading to the bug is only possible for bug-owners. You have to upload it here in the forum.

              M Offline
              M Offline
              marcbf
              wrote on last edited by
              #16

              That's what I meant. I'm not allowed to upload the code here.

              While I'm at it, I've made some progress. Essentially it boils down to me having done too much instead of too little. What I needed to do was simply to emit a signal in the frozen header resize event and then in the main view call updateFrozenTableGeometry() instead of trying to force resizing inside the frozen header itself.

              I'm not completly there yet. Still have a few issues I need to iron out.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                marcbf
                wrote on last edited by
                #17

                Well, it all seems to work reasonably well now. Now I only need to figure out how to synchronize two frozen views (one upper and one lower) so that everything stays in sync. It used to work previously when the upper view didn't resize itself. Now it does, but the size change isn't propagated to the lower one.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  marcbf
                  wrote on last edited by
                  #18

                  Eureka! Seems like I finally cracked the last piece of the puzzle! I need to call updateGeometries() on the linked (lower) table view. That will call sizeHint() on the header views associated with it and thus propagate the size change and sync the upper and lower table views.

                  @Christian-Ehrlicher thanks for all your input and pointing me in the direction of that bug report. (I still think that should be backported to 5.9.x. :-)

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

                    @marcbf nice to hear that it's working now. But I don't think I can convince them to merge it back to 5.9 since it's really old, not prioritized and not much people complained about it. So you've a good argument updating to 5.12 soon :)

                    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
                    • M Offline
                      M Offline
                      marcbf
                      wrote on last edited by
                      #20

                      @Christian-Ehrlicher the reason I'm banging on about 5.9 is that it's the latest long time support branch. Since I'm not doing my own thing with Qt but rather working at a company long term support it quite important to us. We don't have the luxury to upgrade to a newer Qt version every month or so. But maybe I should just get in touch with commercial support about this. :-)

                      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