Originally Posted by
d_stranz
Remove the two show() calls for the child widgets. They will be "shown" when your myWidget instance is shown. And add the "setLayout()" call instead.
If myWidget is derived from QWidget and you intend for it to be the central widget for a QMainWindow, then you need to call setCentralWidget() with the pointer in your main window constructor. If it is meant to be a standalone, top-level widget (i.e. floating), then at some point in your code you also need to call show() on the myWidget instance.
I have got a QStackedWidget in my MainWindow and I call setCentralWidget there:
setCentralWidget(m_StackedWidget);
setCentralWidget(m_StackedWidget);
To copy to clipboard, switch view to plain text mode
and that works perfectly, in the sense that I can change between the two stacked widgets (using slots). myWidget is supposed to "sit on top of" both of these stacked widgets, so maybe there is some interaction here that I have not understood? The widgests in the layout still do not show; without
setLayout(horLayout)
setLayout(horLayout)
To copy to clipboard, switch view to plain text mode
the two widgets in my layout are visible, but free-floating. With
setLayout(horLayout)
setLayout(horLayout)
To copy to clipboard, switch view to plain text mode
they remain hidden, and I see the top stacked widget (they have all got different colours).
Bookmarks