PDA

View Full Version : Problem with QSplitter



kistmaximum
9th June 2012, 14:20
Hi all,

I have a mainwindow with multiple widgets and a horizontal layout.
I tried to add a QSplitter to be able to resize them on runtime.


QSplitter splitter = new QSplitter;
splitter->setChildrenCollapsible(false);
splitter->setOrientation(Qt::Horizontal);
splitter->addWidget(ui->listWidget);
splitter->addWidget(ui->widget);
splitter->addWidget(ui->pushButton);
splitter->addWidget(ui->scrollArea);
splitter->show();

It works fine, except that the mentioned widgets 'pop out' of the mainwindow, leaving an empty mainwindow with only the status and menubar behind.
Take a look:

http://img6.imagebanana.com/img/3qnusvnx/qsplitter.png

How can I keep the widgets inside the mainwindow?
Thanks for the support.

amleto
9th June 2012, 18:51
Widgets with no parent will be a window. Hence your splitter will be in its own window. Just make it the central widget in the mainwindow http://qt-project.org/doc/qt-4.8/qmainwindow.html#setCentralWidget.

kistmaximum
10th June 2012, 01:28
Works like a charm, thank you! :)