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. Set start size of layout in splitter
Forum Update on Tuesday, May 27th 2025

Set start size of layout in splitter

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 11.1k 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.
  • NiagarerN Offline
    NiagarerN Offline
    Niagarer
    wrote on last edited by
    #1

    Hey,
    I am sure, this is just a basic oparation, but playing with the settings and looking to questions didn't help me.
    I want to set the start size of a layout, that is with other layouts in a splitter. But I want to be able to resize it when the program is running (like I normally do with splitters just dragging the corner).
    How can I do this?
    Thanks for answers!

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

      Hi
      The size is determined by the widgets.
      http://doc.qt.io/qt-5/qsplitter.html#details

      "The initial distribution of size between the widgets is determined by multiplying the initial size with the stretch factor. "

      So setting min/max size will alter (on the widgets) where the middle is.

      So as far as i know, you cannot just set the (drag) handle to a position.

      NiagarerN 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        The size is determined by the widgets.
        http://doc.qt.io/qt-5/qsplitter.html#details

        "The initial distribution of size between the widgets is determined by multiplying the initial size with the stretch factor. "

        So setting min/max size will alter (on the widgets) where the middle is.

        So as far as i know, you cannot just set the (drag) handle to a position.

        NiagarerN Offline
        NiagarerN Offline
        Niagarer
        wrote on last edited by Niagarer
        #3

        @mrjj
        I'm sorry, I don't get it...
        The strech factor is 0. Setting it to another does not make a difference.
        I want all the widgets in the layout resizeable by dragging the handle in the window.
        And I have a range min to max of the layout. But the layout always starts with the max possible width. Every time I have to resize is, that it is not so big anymore. I want this to happen automatically...

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

          Ok. Its short, the handle is not just a position. its based on the widgets inserted.
          The doc explains it in details :)

          you can use
          ui->splitter->setSizes(QList<int>() << 200 << 100);
          or set the stretch factor on the widgets
          leftWidget->sizePolicy().setHorizontalStretch(1);
          rightWidget->sizePolicy().setHorizontalStretch(2);

          NiagarerN 1 Reply Last reply
          0
          • mrjjM mrjj

            Ok. Its short, the handle is not just a position. its based on the widgets inserted.
            The doc explains it in details :)

            you can use
            ui->splitter->setSizes(QList<int>() << 200 << 100);
            or set the stretch factor on the widgets
            leftWidget->sizePolicy().setHorizontalStretch(1);
            rightWidget->sizePolicy().setHorizontalStretch(2);

            NiagarerN Offline
            NiagarerN Offline
            Niagarer
            wrote on last edited by Niagarer
            #5

            @mrjj
            I have a vertical layout (no left or right widgets, sorry forgot to mention that). Setting a strech factor to every widget there would take too much time and the number of widgets that are inside the layout can vary (and I still don't get this strech thing).
            I will read the docs, I don't understand the concept behind the resizing of layouts. I can resize them and nothing happens (what kind of resizing is this...), I will maybe by reading the docs.
            I will update here when I am finished. Thanks for your help anyway!

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              should also work on a vertical splitter
              The stretch thing also made me wonder in the beginning but its just a measure for how much each side get
              so if you say 2,1 the first get twice as much .
              Just play with it and it will be clear.

              Im not sure what u mean when you say resizing of layouts.
              They will adjust any widgets inside them. Based on each widget settings.
              The layout itself only have margins and other properties.
              All resize is based on the widgets.

              • I can resize them and nothing happens
                Well then its most likely not setup correctly. :)
              NiagarerN 1 Reply Last reply
              0
              • mrjjM mrjj

                Hi
                should also work on a vertical splitter
                The stretch thing also made me wonder in the beginning but its just a measure for how much each side get
                so if you say 2,1 the first get twice as much .
                Just play with it and it will be clear.

                Im not sure what u mean when you say resizing of layouts.
                They will adjust any widgets inside them. Based on each widget settings.
                The layout itself only have margins and other properties.
                All resize is based on the widgets.

                • I can resize them and nothing happens
                  Well then its most likely not setup correctly. :)
                NiagarerN Offline
                NiagarerN Offline
                Niagarer
                wrote on last edited by
                #7

                @mrjj
                But I can not set the horizontal stretch of a layout in a splitter.
                I am trying to set the width of a layout that is next to other layouts in a horizontal spliter.
                The splitter splits multiple layouts. But in the code, I can not call

                ui->horizontal_layout_1->setHorizontalStretch(2);
                
                mrjjM 1 Reply Last reply
                0
                • NiagarerN Niagarer

                  @mrjj
                  But I can not set the horizontal stretch of a layout in a splitter.
                  I am trying to set the width of a layout that is next to other layouts in a horizontal spliter.
                  The splitter splits multiple layouts. But in the code, I can not call

                  ui->horizontal_layout_1->setHorizontalStretch(2);
                  
                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Niagarer said in Set start size of layout in splitter:

                  ui->horizontal_layout_1

                  This that one of the free floating layouts ?
                  alt text

                  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