Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
mdiareasnippets.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtWidgets>
5
7{
8 QMdiArea *mdiArea = new QMdiArea;
10 QMainWindow *mainWindow = new QMainWindow;
11 mainWindow->setCentralWidget(mdiArea);
13
14 mdiArea->addSubWindow(new QPushButton("Push Me Now!"));
15
16 mainWindow->show();
17}
18
20{
21 QWidget *internalWidget1 = new QWidget;
22 QWidget *internalWidget2 = new QWidget;
23
25 QMdiArea mdiArea;
26 QMdiSubWindow *subWindow1 = new QMdiSubWindow;
27 subWindow1->setWidget(internalWidget1);
28 subWindow1->setAttribute(Qt::WA_DeleteOnClose);
29 mdiArea.addSubWindow(subWindow1);
30
31 QMdiSubWindow *subWindow2 =
32 mdiArea.addSubWindow(internalWidget2);
33
35 subWindow1->show();
36 subWindow2->show();
37
38 mdiArea.show();
39}
The QMainWindow class provides a main application window.
Definition qmainwindow.h:25
The QMdiArea widget provides an area in which MDI windows are displayed.
Definition qmdiarea.h:21
QMdiSubWindow * addSubWindow(QWidget *widget, Qt::WindowFlags flags=Qt::WindowFlags())
Adds widget as a new subwindow to the MDI area.
The QMdiSubWindow class provides a subwindow class for QMdiArea.
void setWidget(QWidget *widget)
Sets widget as the internal widget of this subwindow.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
QPushButton
[1]
void addingSubWindowsExample()
void mainWindowExample()
@ WA_DeleteOnClose
Definition qnamespace.h:321