Important: Please read the Qt Code of Conduct -

Resize widgets within the same QGroupBox

  • So for the QGroupBox, I have three widgets: line edit, label, and a button. I grouped them together using QVBoxLayout. However, they stretch across the whole main window taking all the space. My main question is that since the button is at the bottom, is it possible for the button to not be stretched across the whole main window? I have been trying to look for tutorials or forums but I can't seem to find anything. Also, if it is not too much to ask, I was also wondering if there are two widgets side by side such as two buttons, is it possible to distribute the size of each widget like button 1 40% and button 2 60 %?

  • Lifetime Qt Champion


    You can add a stretch before or after the button so it will be pushed against a border.

    For your second question, you can again use the stretch like described here