Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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);
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 QPushButton widget provides a command button.
Definition qpushbutton.h:20
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7956
void addingSubWindowsExample()
void mainWindowExample()
@ WA_DeleteOnClose
Definition qnamespace.h:320