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 a width to a layout

Set a width to a layout

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 11.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
    durium
    wrote on last edited by
    #1

    Hi everybody !

    I am actually trying to create a window with Qt.

    My window is separated in two parts : one menu that takes approximately 20% of the window's width and another taking 80%.

    Thus i basically have 3 layouts :
    One QHBoxLayout that contains 2 QVBoxLayout. However i can't seem to find a method which would set the first QVBoxLayout width to 20% of the window's size (i must really be a "noob"...).

    Maybe is there another way to build my window ?

    Thanks !

    1 Reply Last reply
    0
    • C Offline
      C Offline
      culhacker
      wrote on last edited by
      #2

      You can't set width to layout)). It's layout. You can set Stretch.

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

        Hi thanks for your answer i can't seem to find info on stretch (sends back to setStrech which sends back to strech...).
        Can you tell me more about it ?
        Thanks !

        1 Reply Last reply
        0
        • R Offline
          R Offline
          raaghuu
          wrote on last edited by
          #4

          @
          myHBoxLayout->setStrechFactor(myFirstVBoxLayout,1);
          myHBoxLayout->setStretchFactor(mySecondVBoxLayout,4);
          @
          this will stretch them in accordance to the space occupied by the QHBoxLayout in the window, which in your case seems to be the whole window...so this should work

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

            ok I've tested and I think I understand !
            Thanks culhacker & raaghuu for your answers !

            1 Reply Last reply
            0
            • R Offline
              R Offline
              raaghuu
              wrote on last edited by
              #6

              We're all here to learn from(and help) each other... :) Happy Coding..!

              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