summaryrefslogtreecommitdiffstats
path: root/examples/widgets/mainwindows/mdi/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/mainwindows/mdi/mainwindow.cpp')
-rw-r--r--examples/widgets/mainwindows/mdi/mainwindow.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/examples/widgets/mainwindows/mdi/mainwindow.cpp b/examples/widgets/mainwindows/mdi/mainwindow.cpp
index ab61dd6561..d58a47e669 100644
--- a/examples/widgets/mainwindows/mdi/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mdi/mainwindow.cpp
@@ -95,16 +95,22 @@ void MainWindow::open()
return;
}
- MdiChild *child = createMdiChild();
- if (child->loadFile(fileName)) {
+ if (openFile(fileName))
statusBar()->showMessage(tr("File loaded"), 2000);
- child->show();
- } else {
- child->close();
- }
}
}
+bool MainWindow::openFile(const QString &fileName)
+{
+ MdiChild *child = createMdiChild();
+ const bool succeeded = child->loadFile(fileName);
+ if (succeeded)
+ child->show();
+ else
+ child->close();
+ return succeeded;
+}
+
void MainWindow::save()
{
if (activeMdiChild() && activeMdiChild()->save())