Hi all,

I want to create a QMainWindow when I click in a QPushButton.

I have this code in the SLOT of the QPushButton that is called when the clicked() SIGNAL is emitted:

Qt Code:
  1. QMainWindow* myQMainWindow = new QMainWindow(this);
  2. myQMainWindow->setWindowModality(Qt::WindowModal);
  3. myQMainWindow->setGeometry(geometry());
  4. myQMainWindow->move(QPoint(100, 100));
  5.  
  6. QVBoxLayout *layout = new QVBoxLayout(myQMainWindow->centralWidget());
  7. myQMainWindow->setLayout(layout);
  8. QPushButton* pushButton = new QPushButton("hello", myQMainWindow->centralWidget());
  9. myQMainWindow->show();
To copy to clipboard, switch view to plain text mode 

The window appears but the button with text "hello" doesn't shown. Why?

Regards.