[SOLVED] MainWindow has already a Layout, what can i do for this?
-
When trying to do this is a mainwindow a get an error that the mainwindow has already a layout.. (If u want the excact error i will reproduce it )
@ mainLayout = new QVBoxLayout;
mainLayout->addWidget(optionsGroupBox);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);@P.S This happens only to mainwindow.. i am capable of doing it in every other dialog..
-
Use setCentralWidget() instead to provide QMW with a "main" object.
-
The QMainWindow has a centralWidget so one option is to set the layout to a widget/frame and then you can use setCentralWidget().
@mainLayout = new QVBoxLayout;
mainLayout->addWidget(optionsGroupBox);
mainLayout->addLayout(buttonsLayout);
QWidget *widget = new QWidget();widget->setLayout(mainLayout);
setCentralWidget(widget);@see "Qt Main Window Framework":http://qt-project.org/doc/qt-5.0/qmainwindow.html#details