Unsolved Is it possible to add a QmainWindow to another Qmainwindow/QWidget ?
-
Hi,
Is it possible to add a QmainWindow to another Qmainwindow/QWidget ?
-
Hi,
While unusual, there's nothing stopping your from doing it.
-
Hi @SGaist
In QmainWindow i have only
addActions
addDockWidget
addToolBarthere is nothing addQmainWindow ?
How can i do that ?
-
@BhanuKiranChaluvadi Like this?
MainWindow w; w.show();
There is no addMainWindow() because usually an application only has one main window. That's why it is called main window. As @SGaist already said it is unusual to create more than one main window. You can use QDialog for dialog windows or just QWidget for any other window.
-
@BhanuKiranChaluvadi
You can use a QMainWindow like any other QWidget. It just has some convenience features found in typical main windows.So use QMainWindow::setCentralWidget()
-
What you are you trying to do ? Can you give more info ? You may be trying something which is not a best practice. Your sample program would help.
-
@raven-worx said:
You can use a QMainWindow like any other QWidget. It just has some convenience features found in typical main windows.
So use QMainWindow::setCentralWidget()
Correct answer but a caveat: you'll have to call setWindowFlags(Qt::Widget); on the inner QMainWindow or it won't show up
-
@VRonin said:
Correct answer but a caveat: you'll have to call setWindowFlags(Qt::Widget); on the inner QMainWindow or it won't show up
no, thats not true.
Actually you would have to set the flag (Qt::Window) explicitly again if you want it the otherway around, since a reparenting happened. -
What I mean is the
QMainWindow sets the Qt::Window flag itself, and will hence always be created as a top-level widget.
from http://doc.qt.io/qt-5/qmainwindow.html#QMainWindow
So contrary to other QWidgets you have to undo this default to use it as a child widget
-
@VRonin
no!
As i said, as soon as you add the second window the first one a reparenting is happening. So you do not have to change the window flags again.Just try it yourself, and see that it is not correct.
-
hi
I inserted a mainwindow into the main window to fool around with Docks.
You need set nothing to allow it. Just put it in.
but as Dheerendra askAre you sure you need this?
If you give some details of the actual goal , maybe there is more
usual solution.