QMdiArea Class Reference

[ QtGui module]

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

继承 QAbstractScrollArea .

类型

方法

Qt Signals


详细描述

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

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:

     QMainWindow *mainWindow = new QMainWindow;
     mainWindow->setCentralWidget(mdiArea);
			

Unlike the window managers for top-level windows, all window flags ( Qt.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 ,和 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 () 和 for activateNextSubWindow () and acivatePreviousSubWindow(). Also, it is used when cascading or tiling the windows with cascadeSubWindows () 和 tileSubWindows ().

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

注意: The default scroll bar property for QMdiArea is Qt.ScrollBarAlwaysOff .


类型文档编制

QMdiArea.AreaOption

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

常量 描述
QMdiArea.DontMaximizeSubWindowOnActivation 0x1 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 AreaOptions type is a typedef for QFlags <AreaOption>. It stores an OR combination of AreaOption values.

QMdiArea.ViewMode

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

常量 描述
QMdiArea.SubWindowView 0 Display sub-windows with window frames (default).
QMdiArea.TabbedView 1 Display sub-windows with tabs in a tab bar.

该枚举在 Qt 4.4 引入或被修改。

另请参阅 setViewMode ().

QMdiArea.WindowOrder

Specifies the criteria to use for ordering the list of child windows returned by subWindowList ()。函数 cascadeSubWindows () and tileSubWindows () follow this order when arranging the windows.

常量 描述
QMdiArea.CreationOrder 0 The windows are returned in the order of their creation.
QMdiArea.StackingOrder 1 The windows are returned in the order in which they are stacked, with the top-most window being last in the list.
QMdiArea.ActivationHistoryOrder 2 The windows are returned in the order in which they were activated.

另请参阅 subWindowList ().


方法文档编制

QMdiArea.__init__ ( self , QWidget   parent  = None)

parent argument, if not None, causes self to be owned by Qt instead of PyQt.

Constructs an empty mdi area. parent 会被传递给 QWidget 的构造函数。

QMdiArea.activateNextSubWindow ( self )

This method is also a Qt slot with the C++ signature void 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 () and QMdiArea.WindowOrder .

QMdiArea.activatePreviousSubWindow ( self )

This method is also a Qt slot with the C++ signature void 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 () and QMdiArea.WindowOrder .

WindowOrder QMdiArea.activationOrder ( self )

QMdiSubWindow QMdiArea.activeSubWindow ( self )

Returns a pointer to the current active subwindow. If no window is currently active, 0 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.

另请参阅 setActiveSubWindow () 和 Qt.WindowState .

QMdiSubWindow QMdiArea.addSubWindow ( self , QWidget   widget , Qt.WindowFlags   flags  = 0)

widget argument has it's ownership transferred to Qt.

添加 widget as a new subwindow to the MDI area. If windowFlags are non-zero, they will override the flags set 在 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 .

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

QBrush QMdiArea.background ( self )

QMdiArea.cascadeSubWindows ( self )

This method is also a Qt slot with the C++ signature void cascadeSubWindows() .

Arranges all the child windows in a cascade pattern.

另请参阅 tileSubWindows ().

QMdiArea.childEvent ( self , QChildEvent   childEvent )

重实现自 QObject.childEvent ().

QMdiArea.closeActiveSubWindow ( self )

This method is also a Qt slot with the C++ signature void closeActiveSubWindow() .

Closes the active subwindow.

另请参阅 closeAllSubWindows ().

QMdiArea.closeAllSubWindows ( self )

This method is also a Qt slot with the C++ signature void 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.

另请参阅 closeActiveSubWindow ().

QMdiSubWindow QMdiArea.currentSubWindow ( self )

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

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

另请参阅 activeSubWindow () 和 QApplication.activeWindow ().

bool QMdiArea.documentMode ( self )

bool QMdiArea.event ( self , QEvent   event )

重实现自 QObject.event ().

bool QMdiArea.eventFilter ( self , QObject   object , QEvent   event )

重实现自 QObject.eventFilter ().

QSize QMdiArea.minimumSizeHint ( self )

重实现自 QWidget.minimumSizeHint ().

QMdiArea.paintEvent ( self , QPaintEvent   paintEvent )

重实现自 QWidget.paintEvent ().

QMdiArea.removeSubWindow ( self , QWidget   widget )

移除 widget from the MDI area. The widget must be either a QMdiSubWindow 或 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 0 and it is removed, but if an internal widget is passed in the child widget is set to 0 but the QMdiSubWindow is not removed.

另请参阅 addSubWindow ().

QMdiArea.resizeEvent ( self , QResizeEvent   resizeEvent )

重实现自 QWidget.resizeEvent ().

QMdiArea.scrollContentsBy ( self , int  dx , int  dy )

重实现自 QAbstractScrollArea.scrollContentsBy ().

QMdiArea.setActivationOrder ( self , WindowOrder   order )

QMdiArea.setActiveSubWindow ( self , QMdiSubWindow   window )

This method is also a Qt slot with the C++ signature void setActiveSubWindow(QMdiSubWindow*) .

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

另请参阅 activeSubWindow ().

QMdiArea.setBackground ( self , QBrush   background )

QMdiArea.setDocumentMode ( self , bool  enabled )

QMdiArea.setOption ( self , AreaOption   option , bool  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 and testOption ().

QMdiArea.setTabPosition ( self , QTabWidget.TabPosition   position )

QMdiArea.setTabsClosable ( self , bool  closable )

QMdiArea.setTabShape ( self , QTabWidget.TabShape   shape )

QMdiArea.setTabsMovable ( self , bool  movable )

QMdiArea.setupViewport ( self , QWidget   视口 )

This slot is called by QAbstractScrollArea after setViewport () has been called. Reimplement this function in a subclass of QMdiArea to initialize the new 视口 before it is used.

另请参阅 setViewport ().

QMdiArea.setViewMode ( self , ViewMode   mode )

QMdiArea.showEvent ( self , QShowEvent   showEvent )

重实现自 QWidget.showEvent ().

QSize QMdiArea.sizeHint ( self )

重实现自 QWidget.sizeHint ().

list-of-QMdiSubWindow QMdiArea.subWindowList ( self , WindowOrder   order  = QMdiArea.CreationOrder)

Returns a list of all subwindows in the MDI area. If order is CreationOrder (默认), 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 , windows are listed according to their recent activation history.

另请参阅 WindowOrder .

QTabWidget.TabPosition QMdiArea.tabPosition ( self )

bool QMdiArea.tabsClosable ( self )

QTabWidget.TabShape QMdiArea.tabShape ( self )

bool QMdiArea.tabsMovable ( self )

bool QMdiArea.testOption ( self , AreaOption   opton )

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

另请参阅 AreaOption and setOption ().

QMdiArea.tileSubWindows ( self )

This method is also a Qt slot with the C++ signature void tileSubWindows() .

Arranges all child windows in a tile pattern.

另请参阅 cascadeSubWindows ().

QMdiArea.timerEvent ( self , QTimerEvent   timerEvent )

重实现自 QObject.timerEvent ().

ViewMode QMdiArea.viewMode ( self )

bool QMdiArea.viewportEvent ( self , QEvent   event )

重实现自 QAbstractScrollArea.viewportEvent ().


Qt Signal Documentation

void subWindowActivated (QMdiSubWindow*)

This is the default overload of this signal.

QMdiArea emits this signal after window has been activated. When window is 0, QMdiArea has just deactivated its last active window, and there are no active windows on the workspace.

另请参阅 QMdiArea.activeSubWindow ().