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.

    mainLayout->addWidget(horizontalGroupBox);
    mainLayout->addWidget(gridGroupBox);
    mainLayout->addWidget(formGroupBox);

    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?
    Thanks



  • Hi,

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

    @
    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.