Qt logo

QWorkspace Class Reference


The QWorkspace widget provides a workspace that can contain decorated windows as opposed to frameless child widgets. QWorkspace makes it easy to implement a multidocument interface (MDI). More...

#include <qworkspace.h>

Inherits QWidget.

List of all member functions.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

The QWorkspace widget provides a workspace that can contain decorated windows as opposed to frameless child widgets. QWorkspace makes it easy to implement a multidocument interface (MDI).

An MDI application has one main window that has a menubar. The central widget of this main window is a workspace. The workspace itself contains zero, one or several document windows, each of which displays a document.

The menubar and the toolbars act as a roadmap to the application. You get to keep the same map all the time, even if you open three different documents in three different child windows and switch around among them.

The workspace itself is an ordinary Qt widget. It has a standard constructor that takes a parent widget and an object name. Document windows, so-called MDI windows, are also ordinary Qt widgets. They may even be main windows itself, in case your application design requires specific toolbars or statusbars for them. The only special thing about them is that you create them with the workspace as parent widget. The rest of the magic happens behind the scenes. All you have to do is call QWidget::show() or QWidget::showMaximized() (as you would do with normal toplevel windows) and the document window appears as MDI window inside the workspace.

In addition to show, QWidget::hide(), QWidget::showMaximized(), QWidget::showNormal(), QWidget::showMinimized() also work as expected for the document windows.

A document window becomes active when it gets the focus. This can be achieved by calling QWidget::setFocus(). The workspace emits a signal clientActivated() when it detects the activation change. The active client itself can be obtained with activeClient().

The convenience function clientList() returns a list of all document windows. This is especially useful to create a popup menu "&Windows" on the fly.

QWorkspace provides two built-in layout strategies for child windows, cascade() and tile(). Both are slots, so you can easily provide them in the windows menu.

If the user clicks on the frame of an MDI window, this window becomes active, i.e. it gets the focus. For that reason, all direct children of a QWorkspace have to be focus enabled. If your MDI window does not handle focus itself, use QWidget::setFocusProxy() to install a focus-enabled child widget as focus proxy.

In case the toplevel window contains a menu bar and a MDI child window is maximized, QWorkspace places the child window's minimize, restore and close buttons on the menubar, in the same relative positions as in the title bar of the child window. Futhermore, on the very left, the menubar will contain a window operation menu with the child window's icon as label.

In general, modern GUI applications should be document-centric rather then application-centric. A single document interface (SDI) guarantees a bijective mapping between open documents and open windows on the screen. This makes the model very easy to understand and therefore the natural choice for applications targeted on inexperienced users. Typical examples are modern wordprocessors. Although most wordprocessors were MDI applications in the past, user interface studies showed that many users never really understood the model.

If an application is supposed to be used mostly by experienced users, a multiple document interface may neverthless make sense. A typical example is an integrated development environment (IDE). With an IDE, a document is a project. The project itself consists of an arbitrary number of subdocuments, mainly code files but also other data. MDI offers a good possibility to group these subdocuments together in one main window. The menubar and the toolbars form a stable working context for the users to grasp and it is crystal-clear which subdocuments belong together. Furthermore, the user effort for window management tasks such as positioning, stacking and sizing is significantly reduced.

An alternative to MDI with QWorkspace is a multipane structure. This can be achived by tiling the main window into separate panes with a QSplitter


Member Function Documentation

QWorkspace::QWorkspace ( QWidget * parent=0, const char * name=0 )

Constructs a workspace with a parent and a name

QWorkspace::~QWorkspace ()

Destructor.

QWidgetQWorkspace::activeClient () const

Returns the active client, or 0 if no client is active.

void QWorkspace::cascade () [slot]

Arranges all child windows in a cascade pattern

See also: tile().

void QWorkspace::childEvent ( QChildEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

void QWorkspace::clientActivated ( QWidget * w ) [signal]

This signal is emitted when the client widget w becomes active.

See also: activeClient() and clientList().

QWidgetList QWorkspace::clientList () const

Returns a list of all clients.

bool QWorkspace::eventFilter ( QObject * o, QEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

void QWorkspace::resizeEvent ( QResizeEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QWorkspace::showEvent ( QShowEvent * e ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QWorkspace::tile () [slot]

Arranges all child windows in a tile pattern

See also: cascade().


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-2000 Troll Tech, all rights reserved.


Copyright İ 2000 Troll TechTrademarks
Qt version 2.1.0 (pre-release)