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. Resize widgets in a splitter
Forum Update on Monday, May 27th 2025

Resize widgets in a splitter

Scheduled Pinned Locked Moved Unsolved General and Desktop
adjustsplitter
6 Posts 4 Posters 1.9k 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.
  • N Offline
    N Offline
    nzur
    wrote on last edited by
    #1

    Hi, I have a horizontal splitter with 2 widgets.
    The widget on the right is a table with an unknown number of columns.
    I would like to grammatically adjust the splitter position so that the table on the right is fully in view.
    I tried setting the widget on the right sizePolicy to preferred, but it doesn't to the trick.
    Thx in advance

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

      Hi,

      do you mean that you want that table view to always be fully visible ?

      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
      1
      • N Offline
        N Offline
        nzur
        wrote on last edited by
        #3

        Exactly :)

        Cobra91151C 1 Reply Last reply
        0
        • N nzur

          Exactly :)

          Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

          @nzur

          Hi! You can set the setMinimumWidth to the widget and setHorizontalStretch (https://doc.qt.io/qt-5/qsizepolicy.html#setHorizontalStretch) to the QSizePolicy.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            NoumanYosuf
            wrote on last edited by NoumanYosuf
            #5

            @nzur so you want your table widget to get adjusted automatically when splitter is moved ? please correct me if i have misunderstood your question.
            Ideally, resized event is called of the added widgets in qsplitter when splitter is resized. And if the added widgets resize fine individually (when not added to splitter), it should work well.
            Or if they don't and you want to handle resizing in the qsplitter, you can over ride resize event of qsplitter and then resize particular widget.

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nzur
              wrote on last edited by
              #6

              I just wanted to locate the splitter so that all the table columns are visible.
              I tried using QSplitter::setSizes() with the table width but it wasn't updated right after creation.
              I solved it by overriding the table's resizeEvent() and emitting a signal to the parent widget

              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