Create the instance of SM in heap. Currently you are creating in stack so its deleting immediately.
Or you can call exec() instead of show();
So now your code should look like this:
{
connect(p,SIGNAL(clicked()),this,SLOT(showMM()));
layout->addWidget(p);
setLayout(layout);
setWindowTitle("MainMenu");
show();
sm *s = new sm(); // This line is changed
}
mm::mm(QWidget *parent)
: QDialog(parent)
{
QHBoxLayout *layout=new QHBoxLayout;
QPushButton *p = new QPushButton("MM");
connect(p,SIGNAL(clicked()),this,SLOT(showMM()));
layout->addWidget(p);
setLayout(layout);
setWindowTitle("MainMenu");
show();
sm *s = new sm(); // This line is changed
}
To copy to clipboard, switch view to plain text mode
Bookmarks