内容表

上一话题

QMainWindow

下一话题

QMdiSubWindow

QMdiArea

QMdiArea widget provides an area in which MDI windows are displayed. 更多

Inheritance diagram of PySide2.QtWidgets.QMdiArea

概要

函数

信号

详细描述

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().

Subwindows in 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 subWindowActivated() 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() 和对于 activateNextSubWindow() and activatePreviousSubWindow() . Also, it is used when cascading or tiling the windows with cascadeSubWindows() and tileSubWindows() .

QMdiArea provides two built-in layout strategies for subwindows: cascadeSubWindows() and tileSubWindows() . Both are slots and are easily connected to menu entries.

mdi-cascade1

mdi-tile2

注意

The default scroll bar property for QMdiArea is ScrollBarAlwaysOff .

另请参阅

QMdiSubWindow

class QMdiArea ( [ parent=None ] )
param parent

QWidget

Constructs an empty mdi area. parent 会被传递给 QWidget ‘s constructor.

PySide2.QtWidgets.QMdiArea. AreaOption

This enum describes options that customize the behavior of the QMdiArea .

常量

描述

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 functions cascadeSubWindows() and tileSubWindows() follow this order when arranging the windows.

常量

描述

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.

另请参阅

subWindowList()

PySide2.QtWidgets.QMdiArea. ViewMode

This enum describes the view mode of the area; i.e. how sub-windows will be displayed.

常量

描述

QMdiArea.SubWindowView

Display sub-windows with window frames (default).

QMdiArea.TabbedView

Display sub-windows with tabs in a tab bar.

另请参阅

setViewMode()

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 .

另请参阅

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 .

另请参阅

activateNextSubWindow() WindowOrder

PySide2.QtWidgets.QMdiArea. activationOrder ( )
返回类型

WindowOrder

PySide2.QtWidgets.QMdiArea. activeSubWindow ( )
返回类型

QMdiSubWindow

Returns a pointer to the current active subwindow. If no window is currently active, None 被返回。

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.

另请参阅

setActiveSubWindow() WindowState

PySide2.QtWidgets.QMdiArea. addSubWindow ( widget [ , flags=Qt.WindowFlags() ] )
参数
返回类型

QMdiSubWindow

添加 widget as a new subwindow to the MDI area. If windowFlags are non-zero, they will override the flags set on the widget.

widget can be either a QMdiSubWindow or another QWidget (in which case the MDI area will create a subwindow and set the widget as the internal widget).

注意

Once the subwindow has been added, its parent will be the viewport widget QMdiArea .

mdiArea = QMdiArea()
subWindow1 = QMdiSubWindow()
subWindow1.setWidget(internalWidget1)
subWindow1.setAttribute(Qt.WA_DeleteOnClose)
mdiArea.addSubWindow(subWindow1)
subWindow2 = QMdiSubWindow()
    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.

另请参阅

removeSubWindow()

PySide2.QtWidgets.QMdiArea. background ( )
返回类型

QBrush

另请参阅

setBackground()

PySide2.QtWidgets.QMdiArea. cascadeSubWindows ( )

Arranges all the child windows in a cascade pattern.

另请参阅

tileSubWindows()

PySide2.QtWidgets.QMdiArea. closeActiveSubWindow ( )

Closes the active subwindow.

PySide2.QtWidgets.QMdiArea. closeAllSubWindows ( )

Closes all subwindows by sending a QCloseEvent to each window. You may receive subWindowActivated() 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.

PySide2.QtWidgets.QMdiArea. currentSubWindow ( )
返回类型

QMdiSubWindow

Returns a pointer to the current subwindow, or None if there is no current subwindow.

This function will return the same as activeSubWindow() QApplication containing QMdiArea is active.

PySide2.QtWidgets.QMdiArea. documentMode ( )
返回类型

bool

另请参阅

setDocumentMode()

PySide2.QtWidgets.QMdiArea. removeSubWindow ( widget )
参数

widget QWidget

移除 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 QMdiSubWindow is not removed.

另请参阅

addSubWindow()

PySide2.QtWidgets.QMdiArea. setActivationOrder ( order )
参数

order WindowOrder

另请参阅

activationOrder()

PySide2.QtWidgets.QMdiArea. setActiveSubWindow ( window )
参数

window QMdiSubWindow

Activates the subwindow window 。若 window is None , any current active window is deactivated.

另请参阅

activeSubWindow()

PySide2.QtWidgets.QMdiArea. setBackground ( background )
参数

background QBrush

另请参阅

background()

PySide2.QtWidgets.QMdiArea. setDocumentMode ( enabled )
参数

enabled bool

另请参阅

documentMode()

PySide2.QtWidgets.QMdiArea. setOption ( option [ , on=true ] )
参数

on is true, option is enabled on the MDI area; otherwise it is disabled. See AreaOption for the effect of each option.

另请参阅

AreaOption testOption()

PySide2.QtWidgets.QMdiArea. setTabPosition ( position )
参数

position TabPosition

另请参阅

tabPosition()

PySide2.QtWidgets.QMdiArea. setTabShape ( shape )
参数

shape TabShape

另请参阅

tabShape()

PySide2.QtWidgets.QMdiArea. setTabsClosable ( closable )
参数

closable bool

另请参阅

tabsClosable()

PySide2.QtWidgets.QMdiArea. setTabsMovable ( movable )
参数

movable bool

另请参阅

tabsMovable()

PySide2.QtWidgets.QMdiArea. setViewMode ( mode )
参数

mode ViewMode

另请参阅

viewMode()

PySide2.QtWidgets.QMdiArea. subWindowActivated ( arg__1 )
参数

arg__1 QMdiSubWindow

PySide2.QtWidgets.QMdiArea. subWindowList ( [ order=CreationOrder ] )
参数

order WindowOrder

返回类型

Returns a list of all subwindows in the MDI area. If order is CreationOrder (the default), the windows are sorted in the order in which they were inserted into the workspace. If order is StackingOrder , the windows are listed in their stacking order, with the topmost window as the last item in the list. If order is ActivationHistoryOrder , the windows are listed according to their recent activation history.

另请参阅

WindowOrder

PySide2.QtWidgets.QMdiArea. tabPosition ( )
返回类型

TabPosition

另请参阅

setTabPosition()

PySide2.QtWidgets.QMdiArea. tabShape ( )
返回类型

TabShape

另请参阅

setTabShape()

PySide2.QtWidgets.QMdiArea. tabsClosable ( )
返回类型

bool

另请参阅

setTabsClosable()

PySide2.QtWidgets.QMdiArea. tabsMovable ( )
返回类型

bool

另请参阅

setTabsMovable()

PySide2.QtWidgets.QMdiArea. testOption ( opton )
参数

opton AreaOption

返回类型

bool

返回 true if option 被启用;否则返回 false .

另请参阅

AreaOption setOption()

PySide2.QtWidgets.QMdiArea. tileSubWindows ( )

Arranges all child windows in a tile pattern.

PySide2.QtWidgets.QMdiArea. viewMode ( )
返回类型

ViewMode

另请参阅

setViewMode()