QLayout: Attempting to add QLayout "" to stacked "", which already has a layout |
A QMainWindow
needs
to have a central widget. Try this code:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
classA * objA = new classA(this);
classB * objB = new classB(this);
QWidget * q = new QWidget();
setCentralWidget(q);
QVBoxLayout * mainLayout = new QVBoxLayout(this);
q->setLayout(mainLayout);
mainLayout->addWidget(objA);
mainLayout->addWidget(objB);
}