PDA

View Full Version : QMdiArea addSubWindow is not showing window when called from slot



cranfss
12th May 2010, 00:52
I am passing a MdiArea into a QWidget *child:


mdiArea = new QMdiArea;
setCentralWidget(mdiArea);

tabWidget = new QTabWidget;
QWidget *child = new parametertab(tabWidget, mdiArea);

mdiArea->addSubWindow(child); //this addSubWindow works as expected


Inside the parametertab constructor, I can addsubwindow, but it does not work when I addsubwindow from within a slot. It does add the window to the subWindowList, and does not produce a warning. Any idea why it does not display the window?


class parametertab : public QWidget
{
...
private slots:
void runsim();
...
}

parametertab::parametertab(QTabWidget *tW, QMdiArea *ma, QWidget *parent)
: QWidget(parent)
{
...
QWidget *child = new QTextEdit;
mdiArea->addSubWindow(child); //this works as expected
...
}

void parametertab::runsim()
{
QWidget *child = new QTextEdit;
mdiArea->addSubWindow(child); //does not show window?
}

cranfss
12th May 2010, 17:18
A little more info. The signal is from a push button:

connect(buttonRun, SIGNAL(clicked()),
this, SLOT(runsim()));

cranfss
13th May 2010, 17:46
Now working. Had to add activateWindow() and raise() to get it to show.



void parametertab::runsim()
{
QWidget *child = new QTextEdit;
mdiArea->addSubWindow(child);
child->activateWindow();
child->raise();
}