I'm creating a new subuclass of QWidget
with: new TestView;
When I call that statement, a new window opens.
Further when I add this widget to a layout, the window "closes" and the widget is shown in the layout as it should in the first place.
How do I make sure that the widget isn't displayed as a new window?
Can anybody help me?
How do I make sure that the widget isn't displayed as a new window?
It happens because your widget is visible before you add it to the layout. Either you are calling show()
or raise()
early on your TestView
object, or you do the same on a parent widget between its creation and the moment it is added to the layout.
If you are making visible your widgets in their constructors, that's a really bad idea.