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. horizontalHeaderMinimumSectionSize not respected for last column in QTableView - actual value use seems greater than property value
Qt 6.11 is out! See what's new in the release blog

horizontalHeaderMinimumSectionSize not respected for last column in QTableView - actual value use seems greater than property value

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 3 Posters 1.8k 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.
  • O Offline
    O Offline
    olowo726
    wrote on last edited by
    #1

    Hi,

    I have an issue with horizontalHeaderMinimumSectionSize not being respected for last column in QTableView. When I change the property it applies to all other columns, preventing the user from reducing with below a limit. But for the last column the actual limit used seems to be greater than what I set the property to. For example if I set horizontalHeaderMinimumSectionSize to 5 then the actual minimum size for the last columns seems to be ~50 but it's 5 for all other columns. This is an issue in my application because the last columns needs to be very small and just show a small icon.

    Ideas?

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

      Please provide some code and even better a minimal compilable example. Are you sure you don't have enabled setStretchLastSection?

      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
      • O Offline
        O Offline
        olowo726
        wrote on last edited by
        #3

        I've tested both with and without stretchLastSection. Doesn't make a difference.

        Will provide a minimum code example later today.

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

          One more question - what Qt version and OS do you use?

          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
          • O Offline
            O Offline
            olowo726
            wrote on last edited by
            #5

            Qt 5.15.1, Windows 10

            1 Reply Last reply
            0
            • O Offline
              O Offline
              olowo726
              wrote on last edited by
              #6

              Example:

              https://www.udokaelectronics.com/files/LastTableSectionMinimumSizeExample.zip

              The behavior I'm looking for is that the user shall be able to reduce the size of the last column by using the mouse cursor in the header. Put the cursor on the line between the two columns and drag to the right. Now it's just moved to the right if the user does that.

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

                @olowo726 said in horizontalHeaderMinimumSectionSize not respected for last column in QTableView - actual value use seems greater than property value:

                Now it's just moved to the right if the user does that.

                For me all looks fine. The minimum size of 5 px is respected. Clicking between section 1 and 2 resizes section 1, Clicking between section 2 and the emty spaces section 2 is resized.

                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
                • T Offline
                  T Offline
                  Talya
                  wrote on last edited by
                  #8

                  Maybe it has to do with the width of the TableView?
                  try playing with it...

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    olowo726
                    wrote on last edited by
                    #9

                    @Christian-Ehrlicher I think that the desired behavior is that if you click between section 1 and 2 and drags to the left then the minimum size is respected for section 1 (it is now) and if you drag to the right the minimum size of section 2 shall be respected (it isn't, this is what I would like it to be). Clicking between section 2 and empty space and dragging to the left the minimum size is respected.

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

                      Clicking between section 1 and 2 does not change the size of section 2 at all - at least not in your example.

                      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
                      • O Offline
                        O Offline
                        olowo726
                        wrote on last edited by
                        #11

                        yes, and that's what I think is wrong

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

                          Why?
                          Resizing a section can only be done with the spacer after the section - what's wrong with this? I don't see another behavior e.g. in Windows explorer or Excel or LibreOffice calc...

                          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
                          • O Offline
                            O Offline
                            olowo726
                            wrote on last edited by
                            #13

                            Well, for me when I was testing my application it felt unnatural to no be able to do it but perhaps that's just me.

                            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