Nominate our 2022 Qt Champions!

Set a width to a layout

  • 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 !

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

  • 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 !

  • @
    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 this should work

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

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

Log in to reply