Adding SubWindow to a MDI Area will not work inside a slot function
I am wondering if this is a known bug, or I simply missed something.
What I want to do is simple: Adding a sub window to an MDI area.
this line of code works fine if it inside the constructor of my window class.
But I want to add the subwindow by clicking a button.
if the "adding sub window" code is inside the button's slot function, it will not work anymore. Nothing will appear within the mdi area.
I am developing under Mac OS Lion with Qt4.8
here is my code:
@MainWindow::MainWindow(QWidget *parent) :
addSubWindow= ui->mainToolBar->addAction("Add SubWindow"); connect(addSubWindow,SIGNAL(triggered()),this,SLOT(onAddSubWindow())); //This line can add a sub window to the mdi area //ui->mdiArea->addSubWindow(new QWidget());
//but if add a sub window from a slot function, it will not work. nothing will appear within the mdi area.
here is my qt project that repros this issue :http://dl.dropbox.com/u/3315090/mdibug.zip
This is not a bug, I figured out why after looking at the MDI example.
I need to call SubWindow->show() after I add it to the mdi area.