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. Custom QHeaderView header size problem
Qt 6.11 is out! See what's new in the release blog

Custom QHeaderView header size problem

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.3k 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.
  • A Offline
    A Offline
    achard.ju
    wrote on last edited by
    #1

    Hi everyone,

    I'm trying to subclass QHeaderView to add some behavior i need (context menu with column to show/hide, add a lineEdit in the header to filter columns ...)

    My header is added to a QTreeView with setHeader function.

    My problem is that sections can be resized to a smaller size than the text in the header section. How can i force a minimum size column by column, depending on the header text ?

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

      Hi and welcome to devnet,

      Did you try the minimumSectionSize property ?

      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
      • A Offline
        A Offline
        achard.ju
        wrote on last edited by
        #3

        Hi ! And thanks ;)

        yes i've tried minimumSectionSize and it worked well for all columns.
        By the way i need to manage columns size independently as text in headers are all differents...

        For information i'm stuck with Qt 4.7

        1 Reply Last reply
        0
        • A Offline
          A Offline
          achard.ju
          wrote on last edited by
          #4

          I managed to find a way but i think it's ugly.

          When sectionResized() signal is raised, i manually check if new section size is lower than minimal size i want for the section.
          If not i manually call resizeSection() on the section with my minimal size.

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

            What about sectionSizeHint ?

            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
            • A Offline
              A Offline
              achard.ju
              wrote on last edited by
              #6

              same thing, sizeHint is just a recommended size. It does not limit the minimal size.

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

                Right, well, currently I can't see a better way than your workaround. Are you stuck with a precompiled version of Qt ? If not you could have a look and try to back port the handling you need

                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

                • Login

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