Important: Please read the Qt Code of Conduct -

GroupBox positioning in the main window

  • Dear All,
    I have three group boxes, horizontalGroupBox, gridGroupBox and formGroupBox.
    If I add like that in the program, they all are positioned vertically.


    But I want to arrange them, horizontalGroupBox is the first group box at the first row and
    gridGroupBox and formGroupBox are at the second row and these two are side by side.
    How can I arrange them in the program?

  • Hi,

    I expect mainLayout is a VBoxLayout?
    You can cascade the layouts or use a grid layoud to achieve what you want.

    QGridLayout* mainLayout = ...
    mainLayout->addWidget(horizontalGroupBox, 0, 0, 1, 2);
    mainLayout->addWidget(gridGroupBox, 1, 0);
    mainLayout->addWidget(formGroupBox, 1, 1);

    Disclaimer: written directly from brain, no guarantee... ;-)

Log in to reply