QMdiArea functions, essentially, like a window manager for MDI windows. For instance, it draws the windows it manages on itself and arranges them in a cascading or tile pattern.
QMdiArea is commonly used as the center widget in a
QMainWindow to create MDI applications, but can also be placed in any layout. The following code adds an area to a main window:
mainWindow = QMainWindow() mainWindow.setCentralWidget(mdiArea)
Unlike the window managers for top-level windows, all window flags (
WindowFlags ) are supported by
QMdiArea as long as the flags are supported by the current widget style. If a specific flag is not supported by the style (e.g., the
WindowShadeButtonHint ), you can still shade the window with showShaded().
QMdiArea are instances of
QMdiSubWindow . They are added to an MDI area with
addSubWindow() . It is common to pass a
QWidget , which is set as the internal widget, to this function, but it is also possible to pass a
QMdiSubWindow directly. The class inherits
QWidget , and you can use the same API as with a normal top-level window when programming.
QMdiSubWindow also has behavior that is specific to MDI windows. See the
QMdiSubWindow class description for more details.
A subwindow becomes active when it gets the keyboard focus, or when
setFocus() is called. The user activates a window by moving focus in the usual ways. The MDI area emits the signal when the active window changes, and the
activeSubWindow() function returns the active subwindow.
The convenience function
subWindowList() returns a list of all subwindows. This information could be used in a popup menu containing a list of windows, for example.
The subwindows are sorted by the current
WindowOrder . This is used for the
subWindowList() and for
activatePreviousSubWindow() . Also, it is used when cascading or tiling the windows with
Constructs an empty mdi area.
parent is passed to
QWidget ‘s constructor.
This enum describes options that customize the behavior of the
When the active subwindow is maximized, the default behavior is to maximize the next subwindow that is activated. Set this option if you do not want this behavior.
The windows are returned in the order of their creation.
The windows are returned in the order in which they are stacked, with the top-most window being last in the list.
The windows are returned in the order in which they were activated.
This enum describes the view mode of the area; i.e. how sub-windows will be displayed.
Display sub-windows with window frames (default).
Display sub-windows with tabs in a tab bar.
Gives the keyboard focus to another window in the list of child windows. The window activated will be the next one determined by the current
activation order .
Gives the keyboard focus to another window in the list of child windows. The window activated will be the previous one determined by the current
activation order .
Returns a pointer to the current active subwindow. If no window is currently active,
None is returned.
Subwindows are treated as top-level windows with respect to window state, i.e., if a widget outside the MDI area is the active window, no subwindow will be active. Note that if a widget in the window in which the MDI area lives gains focus, the window will be activated.
- PySide6.QtWidgets.QMdiArea.addSubWindow(widget[, flags=Qt.WindowFlags()])¶
widget as a new subwindow to the MDI area. If
windowFlags are non-zero, they will override the flags set on the widget.
Once the subwindow has been added, its parent will be the viewport widget of the
mdiArea = QMdiArea() subWindow1 = QMdiSubWindow() subWindow1.setWidget(internalWidget1) subWindow1.setAttribute(Qt.WA_DeleteOnClose) mdiArea.addSubWindow(subWindow1) subWindow2 = mdiArea.addSubWindow(internalWidget2)
When you create your own subwindow, you must set the
WA_DeleteOnClose widget attribute if you want the window to be deleted when closed in the MDI area. If not, the window will be hidden and the MDI area will not activate the next subwindow.
QMdiSubWindow that is added to the MDI area.
Arranges all the child windows in a cascade pattern.
Closes the active subwindow.
Closes all subwindows by sending a
QCloseEvent to each window. You may receive signals from subwindows before they are closed (if the MDI area activates the subwindow when another is closing).
Subwindows that ignore the close event will remain open.
Returns a pointer to the current subwindow, or
None if there is no current subwindow.
widget from the MDI area. The
widget must be either a
QMdiSubWindow or a widget that is the internal widget of a subwindow. Note
widget is never actually deleted by
QMdiArea . If a
QMdiSubWindow is passed in, its parent is set to
None and it is removed; but if an internal widget is passed in, the child widget is set to
None and the
QMdiSubWindow is not removed.
Activates the subwindow
None, any current active window is deactivated.
enabled – bool
on is true,
option is enabled on the MDI area; otherwise it is disabled. See
AreaOption for the effect of each option.
closable – bool
movable – bool
- Return type
Returns a list of all subwindows in the MDI area. If
CreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. If
StackingOrder , the windows are listed in their stacking order, with the topmost window as the last item in the list. If
ActivationHistoryOrder , the windows are listed according to their recent activation history.
option is enabled; otherwise returns
Arranges all child windows in a tile pattern.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.