QMdiArea¶

Synopsis¶
Functions¶
def
activationOrder()def
activeSubWindow()def
addSubWindow(widget[, flags=Qt.WindowFlags()])def
background()def
currentSubWindow()def
documentMode()def
removeSubWindow(widget)def
setActivationOrder(order)def
setBackground(background)def
setDocumentMode(enabled)def
setOption(option[, on=true])def
setTabPosition(position)def
setTabShape(shape)def
setTabsClosable(closable)def
setTabsMovable(movable)def
setViewMode(mode)def
subWindowList([order=CreationOrder])def
tabPosition()def
tabShape()def
tabsClosable()def
tabsMovable()def
testOption(opton)def
viewMode()
Slots¶
def
activateNextSubWindow()def
activatePreviousSubWindow()def
cascadeSubWindows()def
closeActiveSubWindow()def
closeAllSubWindows()def
setActiveSubWindow(window)def
tileSubWindows()
Signals¶
def
subWindowActivated(arg__1)
Detailed Description¶
QMdiAreafunctions, 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.QMdiAreais commonly used as the center widget in aQMainWindowto create MDI applications, but can also be placed in any layout. The following code adds an area to a main window:QMainWindow *mainWindow = new QMainWindow; mainWindow->setCentralWidget(mdiArea);Unlike the window managers for top-level windows, all window flags (
WindowFlags) are supported byQMdiAreaas long as the flags are supported by the current widget style. If a specific flag is not supported by the style (e.g., theWindowShadeButtonHint), you can still shade the window with showShaded().Subwindows in
QMdiAreaare instances ofQMdiSubWindow. They are added to an MDI area withaddSubWindow(). It is common to pass aQWidget, which is set as the internal widget, to this function, but it is also possible to pass aQMdiSubWindowdirectly.The class inheritsQWidget, and you can use the same API as with a normal top-level window when programming.QMdiSubWindowalso has behavior that is specific to MDI windows. See theQMdiSubWindowclass 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 thesubWindowActivated()signal when the active window changes, and theactiveSubWindow()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 thesubWindowList()and foractivateNextSubWindow()andactivatePreviousSubWindow(). Also, it is used when cascading or tiling the windows withcascadeSubWindows()andtileSubWindows().
QMdiAreaprovides two built-in layout strategies for subwindows:cascadeSubWindows()andtileSubWindows(). Both are slots and are easily connected to menu entries.
Note
The default scroll bar property for
QMdiAreaisScrollBarAlwaysOff.See also
- class PySide2.QtWidgets.QMdiArea([parent=None])¶
- param parent:
Constructs an empty mdi area.
parentis passed toQWidget‘s constructor.
- PySide2.QtWidgets.QMdiArea.AreaOption¶
This enum describes options that customize the behavior of the
QMdiArea.Constant
Description
QMdiArea.DontMaximizeSubWindowOnActivation
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.
- PySide2.QtWidgets.QMdiArea.WindowOrder¶
Specifies the criteria to use for ordering the list of child windows returned by
subWindowList(). The functionscascadeSubWindows()andtileSubWindows()follow this order when arranging the windows.Constant
Description
QMdiArea.CreationOrder
The windows are returned in the order of their creation.
QMdiArea.StackingOrder
The windows are returned in the order in which they are stacked, with the top-most window being last in the list.
QMdiArea.ActivationHistoryOrder
The windows are returned in the order in which they were activated.
See also
- PySide2.QtWidgets.QMdiArea.ViewMode¶
This enum describes the view mode of the area; i.e. how sub-windows will be displayed.
Constant
Description
QMdiArea.SubWindowView
Display sub-windows with window frames (default).
QMdiArea.TabbedView
Display sub-windows with tabs in a tab bar.
See also
- PySide2.QtWidgets.QMdiArea.activateNextSubWindow()¶
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.See also
activatePreviousSubWindow()WindowOrder
- PySide2.QtWidgets.QMdiArea.activatePreviousSubWindow()¶
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.See also
activateNextSubWindow()WindowOrder
- PySide2.QtWidgets.QMdiArea.activationOrder()¶
- Return type:
This property holds the ordering criteria for subwindow lists.
This property specifies the ordering criteria for the list of subwindows returned by
subWindowList(). By default, it is the window creation order.See also
- PySide2.QtWidgets.QMdiArea.activeSubWindow()¶
- Return type:
Returns a pointer to the current active subwindow. If no window is currently active,
Noneis 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.
See also
setActiveSubWindow()WindowState
- PySide2.QtWidgets.QMdiArea.addSubWindow(widget[, flags=Qt.WindowFlags()])¶
- Parameters:
widget –
PySide2.QtWidgets.QWidgetflags –
WindowFlags
- Return type:
Adds
widgetas a new subwindow to the MDI area. IfwindowFlagsare non-zero, they will override the flags set on the widget.The
widgetcan be either aQMdiSubWindowor anotherQWidget(in which case the MDI area will create a subwindow and set thewidgetas the internal widget).Note
Once the subwindow has been added, its parent will be the viewport widget of the
QMdiArea.QMdiArea mdiArea; QMdiSubWindow *subWindow1 = new QMdiSubWindow; subWindow1->setWidget(internalWidget1); subWindow1->setAttribute(Qt::WA_DeleteOnClose); mdiArea.addSubWindow(subWindow1); QMdiSubWindow *subWindow2 = mdiArea.addSubWindow(internalWidget2);
When you create your own subwindow, you must set the
WA_DeleteOnClosewidget 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.Returns the
QMdiSubWindowthat is added to the MDI area.See also
- PySide2.QtWidgets.QMdiArea.background()¶
- Return type:
This property holds the background brush for the workspace.
This property sets the background brush for the workspace area itself. By default, it is a gray color, but can be any brush (e.g., colors, gradients or pixmaps).
- PySide2.QtWidgets.QMdiArea.cascadeSubWindows()¶
Arranges all the child windows in a cascade pattern.
See also
- PySide2.QtWidgets.QMdiArea.closeActiveSubWindow()¶
Closes the active subwindow.
See also
- PySide2.QtWidgets.QMdiArea.closeAllSubWindows()¶
Closes all subwindows by sending a
QCloseEventto each window. You may receivesubWindowActivated()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.
See also
- PySide2.QtWidgets.QMdiArea.currentSubWindow()¶
- Return type:
Returns a pointer to the current subwindow, or
Noneif there is no current subwindow.This function will return the same as
activeSubWindow()if theQApplicationcontainingQMdiAreais active.See also
- PySide2.QtWidgets.QMdiArea.documentMode()¶
- Return type:
bool
This property holds whether the tab bar is set to document mode in tabbed view mode..
Document mode is disabled by default.
See also
- PySide2.QtWidgets.QMdiArea.removeSubWindow(widget)¶
- Parameters:
widget –
PySide2.QtWidgets.QWidget
Removes
widgetfrom the MDI area. Thewidgetmust be either aQMdiSubWindowor a widget that is the internal widget of a subwindow. Notewidgetis never actually deleted byQMdiArea. If aQMdiSubWindowis passed in, its parent is set toNoneand it is removed; but if an internal widget is passed in, the child widget is set toNoneand theQMdiSubWindowis not removed.See also
- PySide2.QtWidgets.QMdiArea.setActivationOrder(order)¶
- Parameters:
order –
WindowOrder
This property holds the ordering criteria for subwindow lists.
This property specifies the ordering criteria for the list of subwindows returned by
subWindowList(). By default, it is the window creation order.See also
- PySide2.QtWidgets.QMdiArea.setActiveSubWindow(window)¶
- Parameters:
window –
PySide2.QtWidgets.QMdiSubWindow
Activates the subwindow
window. IfwindowisNone, any current active window is deactivated.See also
- PySide2.QtWidgets.QMdiArea.setBackground(background)¶
- Parameters:
background –
PySide2.QtGui.QBrush
This property holds the background brush for the workspace.
This property sets the background brush for the workspace area itself. By default, it is a gray color, but can be any brush (e.g., colors, gradients or pixmaps).
- PySide2.QtWidgets.QMdiArea.setDocumentMode(enabled)¶
- Parameters:
enabled – bool
This property holds whether the tab bar is set to document mode in tabbed view mode..
Document mode is disabled by default.
See also
- PySide2.QtWidgets.QMdiArea.setOption(option[, on=true])¶
- Parameters:
option –
AreaOptionon – bool
If
onis true,optionis enabled on the MDI area; otherwise it is disabled. SeeAreaOptionfor the effect of each option.See also
AreaOptiontestOption()
- PySide2.QtWidgets.QMdiArea.setTabPosition(position)¶
- Parameters:
position –
TabPosition
This property holds the position of the tabs in tabbed view mode..
Possible values for this property are described by the
TabPositionenum.See also
TabPositionsetViewMode()
- PySide2.QtWidgets.QMdiArea.setTabShape(shape)¶
- Parameters:
shape –
TabShape
This property holds the shape of the tabs in tabbed view mode..
Possible values for this property are
Rounded(default) orTriangular.See also
TabShapesetViewMode()
- PySide2.QtWidgets.QMdiArea.setTabsClosable(closable)¶
- Parameters:
closable – bool
This property holds whether the tab bar should place close buttons on each tab in tabbed view mode..
Tabs are not closable by default.
See also
- PySide2.QtWidgets.QMdiArea.setTabsMovable(movable)¶
- Parameters:
movable – bool
This property holds whether the user can move the tabs within the tabbar area in tabbed view mode..
Tabs are not movable by default.
See also
movablesetViewMode()
- PySide2.QtWidgets.QMdiArea.setViewMode(mode)¶
- Parameters:
mode –
ViewMode
This property holds the way sub-windows are displayed in the
QMdiArea..By default, the
SubWindowViewis used to display sub-windows.See also
ViewModesetTabShape()setTabPosition()
- PySide2.QtWidgets.QMdiArea.subWindowActivated(arg__1)¶
- Parameters:
arg__1 –
PySide2.QtWidgets.QMdiSubWindow
- PySide2.QtWidgets.QMdiArea.subWindowList([order=CreationOrder])¶
- Parameters:
order –
WindowOrder- Return type:
Returns a list of all subwindows in the MDI area. If
orderisCreationOrder(the default), the windows are sorted in the order in which they were inserted into the workspace. IforderisStackingOrder, the windows are listed in their stacking order, with the topmost window as the last item in the list. IforderisActivationHistoryOrder, the windows are listed according to their recent activation history.See also
WindowOrder
- PySide2.QtWidgets.QMdiArea.tabPosition()¶
- Return type:
This property holds the position of the tabs in tabbed view mode..
Possible values for this property are described by the
TabPositionenum.See also
TabPositionsetViewMode()
- PySide2.QtWidgets.QMdiArea.tabShape()¶
- Return type:
This property holds the shape of the tabs in tabbed view mode..
Possible values for this property are
Rounded(default) orTriangular.See also
TabShapesetViewMode()
- PySide2.QtWidgets.QMdiArea.tabsClosable()¶
- Return type:
bool
This property holds whether the tab bar should place close buttons on each tab in tabbed view mode..
Tabs are not closable by default.
See also
- PySide2.QtWidgets.QMdiArea.tabsMovable()¶
- Return type:
bool
This property holds whether the user can move the tabs within the tabbar area in tabbed view mode..
Tabs are not movable by default.
See also
movablesetViewMode()
- PySide2.QtWidgets.QMdiArea.testOption(opton)¶
- Parameters:
opton –
AreaOption- Return type:
bool
Returns
trueifoptionis enabled; otherwise returnsfalse.See also
AreaOptionsetOption()
- PySide2.QtWidgets.QMdiArea.tileSubWindows()¶
Arranges all child windows in a tile pattern.
See also
- PySide2.QtWidgets.QMdiArea.viewMode()¶
- Return type:
This property holds the way sub-windows are displayed in the
QMdiArea..By default, the
SubWindowViewis used to display sub-windows.See also
ViewModesetTabShape()setTabPosition()
© 2022 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.

