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. QSplitter LayoutStretch equivalent?
QtWS25 Last Chance

QSplitter LayoutStretch equivalent?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.7k 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.
  • D Offline
    D Offline
    daviddoria
    wrote on last edited by
    #1

    When using a QHBoxLayout, I can change the relative sizes of each section by setting the LayoutStretch property. E.g. if there are 3 sections, setting it to (2,1,1) makes the first section twice as big as the second two. However, if I switch to a QSplitter, there is no longer this property, and I do not like how it is choosing to split the sections.

    Is it possible to specify these splits in QtDesigner?

    Thanks,

    David

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      Do you mean QSplitter::setStretchFactor(int index, int stretch) ?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        daviddoria
        wrote on last edited by
        #3

        Possibly - but that property doesn't seem to be accessibly through QtDesigner, is that correct?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Doesn't seem so, no. However, can't you just give each of the widgets inside the splitter a stretch factor?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            daviddoria
            wrote on last edited by
            #5

            Hm, using that technique the stretch seems to be applied in the preview, but not directly in the designer?

            I added three buttons to a widget. I clicked the three of them, and did "Layout in Horizontal Splitter". Then I gave the widget a vertical layout (I think this should behave identically if I had instead given it a horizontal layout?). I set the Horizontal Stretch of the first two buttons to 1, and the Horizontal Stretch of the last button to 2. In the designer, all 3 buttons are the same width. When I Form -> Preview, the last button is twice the width (as desired).

            Is this the behavior you would expect? I guess I am confused because in the past I've noticed the stretch of an HBoxLayout seems to be applied directly in the designer?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              azrdev
              wrote on last edited by
              #6

              I've created a feature request to include the layoutStretch property for QSplitter into Qt Designer: https://bugreports.qt.io/browse/QTCREATORBUG-16955

              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