Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
4.5.2
-
None
Description
Steps to reproduce / test case:
Set the setCentralWidget with a QMdiArea not in the constructor: it works only when the view mode is not TabbedView. When it's TabbedView, the activeSubWindow method always returns 0, the currentSubWindows works only at times and even the subWindowActivated signal doesn't work.
The bug can be reproduced with the mdi demo of Qt with a few changes:
- setCentralWidget(mdiArea);
+ mdiArea->setViewMode(QMdiArea::TabbedView);
+ setCentralWidget(new QWidget());
void MainWindow::newFile()
{
+ if (centralWidget() != mdiArea)
+ setCentralWidget(mdiArea);
MdiChild *child = createMdiChild();
child->newFile();
child->show();
}
void MainWindow::open()
{
QString fileName = QFileDialog::getOpenFileName(this);
if (!fileName.isEmpty()) {
QMdiSubWindow *existing = findMdiChild(fileName);
if (existing) {
mdiArea->setActiveSubWindow(existing);
return;
}
+ if (centralWidget() != mdiArea)
+ setCentralWidget(mdiArea);
MdiChild *child = createMdiChild();
if (child->loadFile(fileName)) {
statusBar()->showMessage(tr("File loaded"), 2000);
child->show();
} else {
child->close();
}
}
}
As you can see, the open and newFile methods are provided with a statement which sets the central widget to mdiArea if not already set.
I hereby attach the sources to reproduce the bug, which in my opinion is quite an important one.
When executing the samples, just open a file or press new and you will see that the menus are not refreshed and you can't save etc, since the signal i mentioned is not emitted and activeSubWindow always returns 0.
More information:
It has to be noted that when the view mode is not TabbedView, then the bug can not be reproduced.