I have
class MyWidget : public QWidget
{
Q_OBJECT
public:
explicit MyWidget (QWidget *parent);
// ...
};
// here is ALL the code in MyWidget constructor
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
glWidget = new GLWidget(this, cluster);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(glWidget);
setLayout(mainLayout);
setWindowTitle("Visualization");
}
and the main window MainWindow w;
.
I want
w
;QCloseEvent
or with w
(now they are destroyed only after QCloseEvent
);I am creating new instance of MyWidget
like this:
void MainWindow::visualize()
{
MyWidget *widg = new MyWidget(this); // or widg = new MyWidget(0)
widg->show();
widg->raise();
widg->activateWindow();
}
When I try to create widg
with w
as a parent
, widg
appears inside of the w
(in left top corner).
What is the easiest and most clear way to fix that?
Thanks!
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent, Qt::Window)
{
glWidget = new GLWidget(this, cluster);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(glWidget);
setLayout(mainLayout);
setWindowTitle("Visualization");
}
Adding Qt::Window
to the constructor of QWidget
should do what you want.