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. columnWidth glitch
QtWS25 Last Chance

columnWidth glitch

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 1.3k 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.
  • MegamouseM Offline
    MegamouseM Offline
    Megamouse
    wrote on last edited by
    #1

    If I call QTablewidget::columnWidth in my constructor before showing the dialog, then my hidden columns will have 0 width when I unhide them during runtime.

    When I simply leave out the columnWidth call they will show with correct size.

    It doesn't matter if columnWidth was called before or after initially hiding the column. (I thought it might have been set to 0 because of it being hidden). The width before hiding is 150.

    Do you think this is worth a ticket?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Technically, trying to get the size of any GUI component in its constructor doesn't make sense as they have no "physical" representation.

      That said, why are you trying to retrieve the width of columns you are hiding ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • MegamouseM Offline
        MegamouseM Offline
        Megamouse
        wrote on last edited by
        #3

        No I am retrieving the width of columns after they get shown in order to fix a bug where they end up with 0 width despite the use of minimum section size:

        setColumnHidden(col, vis);
        
        if (vis && isVisible() && columnWidth(col) <= horizontalHeader()->minimumSectionSize())
        {
            setColumnWidth(col, horizontalHeader()->minimumSectionSize());
        }
        

        Probably another bug for the bug tracker unless you know the reason for this to happen.
        My assumption is that this has to do with restoring window states.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you provide a minimal compilable example that shows that behaviour ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • MegamouseM Offline
            MegamouseM Offline
            Megamouse
            wrote on last edited by Megamouse
            #5

            I can try. But it will probably take some time.

            I can probably only give you code for the columnWidth glitch, since the other bug has been quite rare

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

              I don't think that you will get a section size smaller than the minimum section size with 5.11 and higher... :)

              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
              • MegamouseM Offline
                MegamouseM Offline
                Megamouse
                wrote on last edited by
                #7

                why do you think that? @Christian-Ehrlicher

                @SGaist I don't think I can reproduce this without my source code. But it's fine. I found a workaround by only doing the size fix on visible Tables. (aka after showing the main window)

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

                  Because of https://bugreports.qt.io/browse/QTBUG-64173

                  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
                  2
                  • MegamouseM Offline
                    MegamouseM Offline
                    Megamouse
                    wrote on last edited by Megamouse
                    #9

                    Hmm that could be it. I should target 5.11 and see if it fixes this issue. I also use setStretchLastSection(true) and resizeColumnsToContents at some point. It wouldn't surprise me if this caused the columns to misbehave.

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

                      If you find issues with 5.11 please provide a minimal, compilable example so we can fix it.

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

                        After reviewing it I am even more confused.
                        My initial statement suggests that simply the call caused the behaviour:
                        When I simply leave out the columnWidth call they will show with correct size. It doesn't matter if columnWidth was called before or after initially hiding the column.

                        But I can't reproduce it anymore and I get the feeling that I missed a detail.
                        My current tests indicate that I might have actually changed the width of hidden items by mistake a some point.
                        That width turns out to be zero.

                        So my latest fix is to simply ignore hidden items regarding any columnWidth call.

                        I'll mark this topic as resolved for now.
                        Although I am still certain that the behaviour happened like I said at some point at least. (simply added a columnWidth(col); somewhere)
                        If I ever manage to find it again I will let you know.

                        1 Reply Last reply
                        0
                        • MegamouseM Offline
                          MegamouseM Offline
                          Megamouse
                          wrote on last edited by
                          #12

                          I found another one. It definitely happens whenever I have sorting enabled while a column is hidden.
                          Sorting by clicking a header and then showing the columns again will result in narrow columns.

                          1 Reply Last reply
                          0
                          • MegamouseM Offline
                            MegamouseM Offline
                            Megamouse
                            wrote on last edited by
                            #13

                            as a workaround i now use my own sorting function that unhides all columns before sorting and hides them again afterwards.

                            Do you think there is an option to achieve that by default?

                            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