1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
3 | |
4 | #include <QtWidgets> |
5 | |
6 | void mainWindowExample() |
7 | { |
8 | QMdiArea *mdiArea = new QMdiArea; |
9 | //! [0] |
10 | QMainWindow *mainWindow = new QMainWindow; |
11 | mainWindow->setCentralWidget(mdiArea); |
12 | //! [0] |
13 | |
14 | mdiArea->addSubWindow(widget: new QPushButton("Push Me Now!")); |
15 | |
16 | mainWindow->show(); |
17 | } |
18 | |
19 | void addingSubWindowsExample() |
20 | { |
21 | QWidget *internalWidget1 = new QWidget; |
22 | QWidget *internalWidget2 = new QWidget; |
23 | |
24 | //! [1] |
25 | QMdiArea mdiArea; |
26 | QMdiSubWindow *subWindow1 = new QMdiSubWindow; |
27 | subWindow1->setWidget(internalWidget1); |
28 | subWindow1->setAttribute(Qt::WA_DeleteOnClose); |
29 | mdiArea.addSubWindow(widget: subWindow1); |
30 | |
31 | QMdiSubWindow *subWindow2 = |
32 | mdiArea.addSubWindow(widget: internalWidget2); |
33 | |
34 | //! [1] |
35 | subWindow1->show(); |
36 | subWindow2->show(); |
37 | |
38 | mdiArea.show(); |
39 | } |
40 |