Home · All Classes · Modules

QMdiSubWindow Class Reference
[QtGui module]

The QMdiSubWindow class provides a subwindow class for QMdiArea. More...

Inherits QWidget.



Qt Signals

Detailed Description

The QMdiSubWindow class provides a subwindow class for QMdiArea.

QMdiSubWindow represents a top-level window in a QMdiArea, and consists of a title bar with window decorations, an internal widget, and (depending on the current style) a window frame and a size grip. QMdiSubWindow has its own layout, which consists of the title bar and a center area for the internal widget.

The most common way to construct a QMdiSubWindow is to call QMdiArea.addSubWindow() with the internal widget as the argument. You can also create a subwindow yourself, and set an internal widget by calling setWidget().

You use the same API when programming with subwindows as with regular top-level windows (e.g., you can call functions such as show(), hide(), showMaximized(), and setWindowTitle()).

Subwindow Handling

QMdiSubWindow also supports behavior specific to subwindows in an MDI area.

By default, each QMdiSubWindow is visible inside the MDI area viewport when moved around, but it is also possible to specify transparent window movement and resizing behavior, where only the outline of a subwindow is updated during these operations. The setOption() function is used to enable this behavior.

The isShaded() function detects whether the subwindow is currently shaded (i.e., the window is collapsed so that only the title bar is visible). To enter shaded mode, call showShaded(). QMdiSubWindow emits the windowStateChanged() signal whenever the window state has changed (e.g., when the window becomes minimized, or is restored). It also emits aboutToActivate() before it is activated.

In keyboard-interactive mode, the windows are moved and resized with the keyboard. You can enter this mode through the system menu of the window. The keyboardSingleStep and keyboardPageStep properties control the distance the widget is moved or resized for each keypress event. When shift is pressed down page step is used; otherwise single step is used.

You can also change the active window with the keyboard. By pressing the control and tab keys at the same time, the next (using the current WindowOrder) subwindow will be activated. By pressing control, shift, and tab, you will activate the previous window. This is equivalent to calling activateNextSubWindow() and activatePreviousSubWindow(). Note that these shortcuts overrides global shortcuts, but not the QMdiAreas shortcuts.

Type Documentation


This enum describes options that customize the behavior of QMdiSubWindow.

Constant Value Description
QMdiSubWindow.RubberBandResize 0x4 If you enable this option, a rubber band control is used to represent the subwindow's outline, and the user resizes this instead of the subwindow itself. As a result, the subwindow maintains its original position and size until the resize operation has been completed, at which time it will receive a single QResizeEvent. By default, this option is disabled.
QMdiSubWindow.RubberBandMove 0x8 If you enable this option, a rubber band control is used to represent the subwindow's outline, and the user moves this instead of the subwindow itself. As a result, the subwindow remains in its original position until the move operation has completed, at which time a QMoveEvent is sent to the window. By default, this option is disabled.

The SubWindowOptions type is a typedef for QFlags<SubWindowOption>. It stores an OR combination of SubWindowOption values.

Method Documentation

QMdiSubWindow.__init__ (self, QWidget parent = None, Qt.WindowFlags flags = 0)

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

Constructs a new QMdiSubWindow widget. The parent and flags arguments are passed to QWidget's constructor.

Instead of using addSubWindow(), it is also simply possible to use setParent() when you add the subwindow to a QMdiArea.

Note that only QMdiSubWindows can be set as children of QMdiArea; you cannot, for instance, write:

 QMdiArea mdiArea;
 QTextEdit editor(&mdiArea); // invalid child widget

See also QMdiArea.addSubWindow().

QMdiSubWindow.changeEvent (self, QEvent changeEvent)

Reimplemented from QWidget.changeEvent().

QMdiSubWindow.childEvent (self, QChildEvent childEvent)

Reimplemented from QObject.childEvent().

QMdiSubWindow.closeEvent (self, QCloseEvent closeEvent)

Reimplemented from QWidget.closeEvent().

QMdiSubWindow.contextMenuEvent (self, QContextMenuEvent contextMenuEvent)

Reimplemented from QWidget.contextMenuEvent().

bool QMdiSubWindow.event (self, QEvent event)

Reimplemented from QObject.event().

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

Reimplemented from QObject.eventFilter().

QMdiSubWindow.focusInEvent (self, QFocusEvent focusInEvent)

Reimplemented from QWidget.focusInEvent().

QMdiSubWindow.focusOutEvent (self, QFocusEvent focusOutEvent)

Reimplemented from QWidget.focusOutEvent().

QMdiSubWindow.hideEvent (self, QHideEvent hideEvent)

Reimplemented from QWidget.hideEvent().

bool QMdiSubWindow.isShaded (self)

Returns true if this window is shaded; otherwise returns false.

A window is shaded if it is collapsed so that only the title bar is visible.

int QMdiSubWindow.keyboardPageStep (self)

int QMdiSubWindow.keyboardSingleStep (self)

QMdiSubWindow.keyPressEvent (self, QKeyEvent keyEvent)

Reimplemented from QWidget.keyPressEvent().

QMdiSubWindow.leaveEvent (self, QEvent leaveEvent)

Reimplemented from QWidget.leaveEvent().

QMdiArea QMdiSubWindow.mdiArea (self)

Returns the area containing this sub-window, or 0 if there is none.

This function was introduced in Qt 4.4.

See also QMdiArea.addSubWindow().

QSize QMdiSubWindow.minimumSizeHint (self)

Reimplemented from QWidget.minimumSizeHint().

QMdiSubWindow.mouseDoubleClickEvent (self, QMouseEvent mouseEvent)

Reimplemented from QWidget.mouseDoubleClickEvent().

QMdiSubWindow.mouseMoveEvent (self, QMouseEvent mouseEvent)

Reimplemented from QWidget.mouseMoveEvent().

QMdiSubWindow.mousePressEvent (self, QMouseEvent mouseEvent)

Reimplemented from QWidget.mousePressEvent().

QMdiSubWindow.mouseReleaseEvent (self, QMouseEvent mouseEvent)

Reimplemented from QWidget.mouseReleaseEvent().

QMdiSubWindow.moveEvent (self, QMoveEvent moveEvent)

Reimplemented from QWidget.moveEvent().

QMdiSubWindow.paintEvent (self, QPaintEvent paintEvent)

Reimplemented from QWidget.paintEvent().

QMdiSubWindow.resizeEvent (self, QResizeEvent resizeEvent)

Reimplemented from QWidget.resizeEvent().

QMdiSubWindow.setKeyboardPageStep (self, int step)

QMdiSubWindow.setKeyboardSingleStep (self, int step)

QMdiSubWindow.setOption (self, SubWindowOption option, bool on = True)

If on is true, option is enabled on the subwindow; otherwise it is disabled. See SubWindowOption for the effect of each option.

See also SubWindowOption and testOption().

QMdiSubWindow.setSystemMenu (self, QMenu systemMenu)

The systemMenu argument has it's ownership transferred to Qt.

Sets systemMenu as the current system menu for this subwindow.

By default, each QMdiSubWindow has a standard system menu.

QActions for the system menu created by QMdiSubWindow will automatically be updated depending on the current window state; e.g., the minimize action will be disabled after the window is minimized.

QActions added by the user are not updated by QMdiSubWindow.

QMdiSubWindow takes ownership of systemMenu; you do not have to delete it. Any existing menus will be deleted.

See also systemMenu() and showSystemMenu().

QMdiSubWindow.setWidget (self, QWidget widget)

The widget argument has it's ownership transferred to Qt.

Sets widget as the internal widget of this subwindow. The internal widget is displayed in the center of the subwindow beneath the title bar.

QMdiSubWindow takes temporary ownership of widget; you do not have to delete it. Any existing internal widget will be removed and reparented to the root window.

See also widget().

QMdiSubWindow.showEvent (self, QShowEvent showEvent)

Reimplemented from QWidget.showEvent().

QMdiSubWindow.showShaded (self)

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

Calling this function makes the subwindow enter the shaded mode. When the subwindow is shaded, only the title bar is visible.

Although shading is not supported by all styles, this function will still show the subwindow as shaded, regardless of whether support for shading is available. However, when used with styles without shading support, the user will be unable to return from shaded mode through the user interface (e.g., through a shade button in the title bar).

See also isShaded().

QMdiSubWindow.showSystemMenu (self)

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

Shows the system menu below the system menu icon in the title bar.

See also setSystemMenu() and systemMenu().

QSize QMdiSubWindow.sizeHint (self)

Reimplemented from QWidget.sizeHint().

QMenu QMdiSubWindow.systemMenu (self)

Returns a pointer to the current system menu, or zero if no system menu is set. QMdiSubWindow provides a default system menu, but you can also set the menu with setSystemMenu().

See also setSystemMenu() and showSystemMenu().

bool QMdiSubWindow.testOption (self, SubWindowOption)

Returns true if option is enabled; otherwise returns false.

See also SubWindowOption and setOption().

QMdiSubWindow.timerEvent (self, QTimerEvent timerEvent)

Reimplemented from QObject.timerEvent().

QWidget QMdiSubWindow.widget (self)

Returns the current internal widget.

See also setWidget().

Qt Signal Documentation

void aboutToActivate ()

This is the default overload of this signal.

QMdiSubWindow emits this signal immediately before it is activated. After the subwindow has been activated, the QMdiArea that manages the subwindow will also emit the subWindowActivated() signal.

See also QMdiArea.subWindowActivated().

void windowStateChanged ( ::Qt::WindowStates, ::Qt::WindowStates)

This is the default overload of this signal.

QMdiSubWindow emits this signal after the window state changes. oldState is the window state before it changed, and newState is the new, current state.

PyQt 4.12.1 for X11Copyright © Riverbank Computing Ltd and The Qt Company 2015Qt 4.8.7