|  | Home · Overviews · Examples

# QWorkspace Class Reference
[com.trolltech.qt.gui module]

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

This class is obsolete. It is provided to keep old source code working. We strongly advise against using it in new code.

Inherits `QWidget`.

## Detailed Description

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

This class is deprecated. Use `QMdiArea` instead.

Multiple Document Interface (MDI) applications are typically composed of a main window containing a menu bar, a toolbar, and a central `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 `QMainWindow`:

        MainWindow::MainWindow()
        {
            workspace = new QWorkspace;
            setCentralWidget(workspace);
            ...
        }

Child windows (MDI windows) are standard Qt widgets that are inserted into the workspace with `addWindow`. As with top-level widgets, you can call functions such as `show`, `hide`, `showMaximized`, and `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 `parentWidget`. The `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 `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 `windowActivated` when the active window changes, and the function `activeWindow` returns a pointer to the active child window, or 0 if no window is active.

The convenience function `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.

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

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

See also `QDockWidget` and MDI Example.