summaryrefslogtreecommitdiffstats
path: root/examples/widgets/mainwindows/mdi/mainwindow.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-09-24 16:15:14 +0200
committerFriedemann Kleint <Friedemann.Kleint@digia.com>2014-09-24 23:07:25 +0200
commit8f2519660b2f8a00492928d3fdb07f0a47ba6934 (patch)
tree8267f0286624a3a0ca81930761161e1c3f7777e4 /examples/widgets/mainwindows/mdi/mainwindow.cpp
parent4b03b18548200db0ad65415c7df7a7665a9ec3d8 (diff)
Polish the mdi example.
Add a command line parser to be able to pass on files. Task-number: QTBUG-35146 Change-Id: I32cbb9ec1e87667076e40a81c66674cf16836b54 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
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())