I\'d like to place QMainWindow instance inside another QWidget (for example centralWidget of another QMainWindow).
I\'m wondering why it doesn\'t work ? QMainWindow
centralwidget = new QMainWindow(this);
centralwidget->setWindowFlags(Qt::Widget);
setCentralWidget(centralwidget);
This should help.
Having the same problem, I found the solution here.
QMainWindow sets its window type to Qt::Window so that it will be in an independent window even if it has a parent (you can confirm this by calling show() on your QMainWindow, and you will see it in its own window). Try adding the line
window->setWindowFlags(Qt::Widget);
after you construct the QMainWindow.
QMainWindow
provides predefined stuff like toolbars and status bars and menu bars in a platform agnostic way (it "does the right thing", without manual intervention). If all you need is a bunch of buttons in a layout, use QWidget
.
You need to make sure each QMainWindow has central
QWidget`, other than that, you should be fine.