Table Of Contents

Previous topic

QX11EmbedWidget

Next topic

QToolButton

QWorkspace

Inheritance diagram of QWorkspace

Synopsis

Functions

Signals

Detailed Description

The PySide.QtGui.QWorkspace widget provides a workspace window that can be used in an MDI application.

This class is deprecated. Use PySide.QtGui.QMdiArea instead.

Multiple Document Interface (MDI) applications are typically composed of a main window containing a menu bar, a toolbar, and a central PySide.QtGui.QWorkspace widget. The workspace itself is used to display a number of child windows, each of which is a widget.

The workspace itself is an ordinary Qt widget. It has a standard constructor that takes a parent widget. Workspaces can be placed in any layout, but are typically given as the central widget in a PySide.QtGui.QMainWindow :

class MainWindow(...):
    def __init__(self):
        self.workspace = QWorkspace()
        self.setCentralWidget(workspace)
        ...

Child windows (MDI windows) are standard Qt widgets that are inserted into the workspace with PySide.QtGui.QWorkspace.addWindow() . As with top-level widgets, you can call functions such as PySide.QtGui.QWidget.show() , PySide.QtGui.QWidget.hide() , PySide.QtGui.QWidget.showMaximized() , and PySide.QtGui.QWidget.setWindowTitle() on a child window to change its appearance within the workspace. You can also provide widget flags to determine the layout of the decoration or the behavior of the widget itself.

To change or retrieve the geometry of a child window, you must operate on its PySide.QtGui.QWidget.parentWidget() . The PySide.QtGui.QWidget.parentWidget() provides access to the decorated frame that contains the child window widget. When a child window is maximised, its decorated frame is hidden. If the top-level widget contains a menu bar, it will display the maximised window’s operations menu to the left of the menu entries, and the window’s controls to the right.

A child window becomes active when it gets the keyboard focus, or when PySide.QtGui.QWidget.setFocus() is called. The user can activate a window by moving focus in the usual ways, for example by clicking a window or by pressing Tab. The workspace emits a signal PySide.QtGui.QWorkspace.windowActivated() when the active window changes, and the function PySide.QtGui.QWorkspace.activeWindow() returns a pointer to the active child window, or 0 if no window is active.

The convenience function PySide.QtGui.QWorkspace.windowList() returns a list of all child windows. This information could be used in a popup menu containing a list of windows, for example. This feature is also available as part of the Window Menu Solution.

PySide.QtGui.QWorkspace provides two built-in layout strategies for child windows: PySide.QtGui.QWorkspace.cascade() and PySide.QtGui.QWorkspace.tile() . Both are slots so you can easily connect menu entries to them.

../../_images/mdi-cascade.png ../../_images/mdi-tile.png

If you want your users to be able to work with child windows larger than the visible workspace area, set the PySide.QtGui.QWorkspace.scrollBarsEnabled() property to true.

See also

PySide.QtGui.QDockWidget MDI Example

class PySide.QtGui.QWorkspace([parent=None])
Parameters:parentPySide.QtGui.QWidget

Constructs a workspace with the given parent .

PySide.QtGui.QWorkspace.WindowOrder

Specifies the order in which child windows are returned from PySide.QtGui.QWorkspace.windowList() .

Constant Description
QWorkspace.CreationOrder The windows are returned in the order of their creation
QWorkspace.StackingOrder The windows are returned in the order of their stacking
PySide.QtGui.QWorkspace.activateNextWindow()

Gives the input focus to the next window in the list of child windows.

PySide.QtGui.QWorkspace.activatePreviousWindow()

Gives the input focus to the previous window in the list of child windows.

PySide.QtGui.QWorkspace.activeWindow()
Return type:PySide.QtGui.QWidget

Returns a pointer to the widget corresponding to the active child window, or 0 if no window is active.

PySide.QtGui.QWorkspace.addWindow(w[, flags=0])
Parameters:
Return type:

PySide.QtGui.QWidget

PySide.QtGui.QWorkspace.arrangeIcons()

Arranges all iconified windows at the bottom of the workspace.

PySide.QtGui.QWorkspace.background()
Return type:PySide.QtGui.QBrush

This property holds the workspace’s background.

PySide.QtGui.QWorkspace.cascade()

Arranges all the child windows in a cascade pattern.

PySide.QtGui.QWorkspace.closeActiveWindow()

Closes the child window that is currently active.

PySide.QtGui.QWorkspace.closeAllWindows()

Closes all child windows.

If any child window fails to accept the close event, the remaining windows will remain open.

PySide.QtGui.QWorkspace.scrollBarsEnabled()
Return type:PySide.QtCore.bool

This property holds whether the workspace provides scroll bars.

If this property is true, the workspace will provide scroll bars if any of the child windows extend beyond the edges of the visible workspace. The workspace area will automatically increase to contain child windows if they are resized beyond the right or bottom edges of the visible area.

If this property is false (the default), resizing child windows out of the visible area of the workspace is not permitted, although it is still possible to position them partially outside the visible area.

PySide.QtGui.QWorkspace.setActiveWindow(w)
Parameters:wPySide.QtGui.QWidget

Makes the child window that contains w the active child window.

PySide.QtGui.QWorkspace.setBackground(background)
Parameters:backgroundPySide.QtGui.QBrush

This property holds the workspace’s background.

PySide.QtGui.QWorkspace.setScrollBarsEnabled(enable)
Parameters:enablePySide.QtCore.bool

This property holds whether the workspace provides scroll bars.

If this property is true, the workspace will provide scroll bars if any of the child windows extend beyond the edges of the visible workspace. The workspace area will automatically increase to contain child windows if they are resized beyond the right or bottom edges of the visible area.

If this property is false (the default), resizing child windows out of the visible area of the workspace is not permitted, although it is still possible to position them partially outside the visible area.

PySide.QtGui.QWorkspace.tile()

Arranges all child windows in a tile pattern.

PySide.QtGui.QWorkspace.windowActivated(w)
Parameters:wPySide.QtGui.QWidget
PySide.QtGui.QWorkspace.windowList([order=CreationOrder])
Parameters:orderPySide.QtGui.QWorkspace.WindowOrder
Return type:

Returns a list of all visible or minimized child windows. If order is CreationOrder (the default), the windows are listed 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.