PDA

View Full Version : QSplitter + multiple layouts? how?



jalla2000
6th November 2008, 13:26
I simply want to split the window in two and use different layouts on either sides.

I have a main window and then i split it in half with a QSplitter. How can i add widgets to the left side of the splitter with a QGridLayout and add widgets to the right side using another layout? I can't add the widgets to the QGridLayout and then add the QGridLayout to the splitter since the layout is not a widget and the splitter does not have a addWidget function... Any help would be much appreciated... :)

EDIT: the splitter does have an addWidget function. but still... it doesn't solve my problem..

spirit
6th November 2008, 13:50
simply create one wiget with a needed layout and the second one with another layout and then add these widget to a splitter using proper method (addWidget).

Rayven
6th November 2008, 13:52
Create two QWidget as holders for the QGridLayout. Then use setLayout( ) to add the layout to the widget.



QWidget *leftSide = new QWidget;
QGridLayout *leftLayout = new QGridLayout;
leftSide->setLayout( leftLayout );
splitter->addWidget( leftSide );

// Add the remaining GUI elements to the layout and repeat for right side


Hope this helps.