Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QMdiArea Class Reference
[QtGui module]

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

 #include <QMdiArea>

Inherits QAbstractScrollArea.

Public Types

Properties

Public Functions

Public Slots

Signals

Protected Slots

Additional Inherited Members


Detailed Description

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

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

QMdiArea provides two built-in layout strategies for child windows: cascadeSubWindows() and tileSubWindows(). Both are slots so you can easily connect menu entries to them.

[Missing image qmdiarea-arrange.png]

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 QMdiSubWindow, QDockWindow, and MDI Example.


Member Type Documentation

enum QMdiArea::WindowOrder

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

ConstantValueDescription
QMdiArea::CreationOrder0The windows are returned in the order of their creation
QMdiArea::StackingOrder1The windows are returned in the order of their stacking


Property Documentation

background : QBrush

This property holds the background brush for the workspace.

This property sets the background brush for the workspace area itself. By default, a gray color is used, but you can use any brush for the background (e.g., colors, gradients or pixmaps) by assigning a custom background brush.

Access functions:

scrollBarsEnabled : bool

This property holds whether the workspace provides scrollbars.

If this property is true, the workspace will provide scrollbars 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.

Access functions:

See also QAbstractScrollArea::horizontalScrollBar() and QAbstractScrollArea::verticalScrollBar().


Member Function Documentation

QMdiArea::QMdiArea ( QWidget * parent = 0 )

Constructs an empty workspace widget. parent is passed to QWidget's constructor.

QMdiArea::~QMdiArea ()

Destroys the workspace.

void QMdiArea::activateNextSubWindow ()   [slot]

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

See also activatePreviousSubWindow().

void QMdiArea::activatePreviousSubWindow ()   [slot]

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

See also activateNextSubWindow().

QMdiSubWindow * QMdiArea::activeSubWindow () const

Returns a pointer to the current active subwindow. If no window is currently active, 0 is returned.

See also setActiveSubWindow().

QMdiSubWindow * QMdiArea::addSubWindow ( QWidget * widget, Qt::WindowFlags windowFlags = 0 )

Adds widget widget as new sub window to the workspace. If windowFlags are non-zero, they will override the flags set on the widget.

Returns the widget used for the window frame.

See also addChildWindow() and removeSubWindow().

void QMdiArea::arrangeMinimizedSubWindows ()   [slot]

Arranges all iconified windows at the bottom of the workspace.

See also cascadeSubWindows() and tileSubWindows().

void QMdiArea::cascadeSubWindows ()   [slot]

Arranges all the child windows in a cascade pattern.

See also tileSubWindows() and arrangeMinimizedSubWindows().

void QMdiArea::closeActiveSubWindow ()   [slot]

Closes the active subwindow.

See also closeAllSubWindows().

void QMdiArea::closeAllSubWindows ()   [slot]

Closes all subwindows by sending one QCloseEvent to each window.

Subwindows that ignore the close event will remain open.

See also closeActiveSubWindow().

void QMdiArea::removeSubWindow ( QWidget * widget )

Removes the widget widget from the workspace.

See also addSubWindow().

void QMdiArea::setActiveSubWindow ( QMdiSubWindow * window )   [slot]

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

See also activeSubWindow().

void QMdiArea::setupViewport ( QWidget * viewport )   [protected slot]

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

See also setViewport().

void QMdiArea::subWindowActivated ( QMdiSubWindow * window )   [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.

See also QMdiArea::activeSubWindow().

QList<QMdiSubWindow *> QMdiArea::subWindowList ( WindowOrder order = CreationOrder ) const

Returns a list of all visible or minimized subwindows. 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.

See also windowList() and WindowOrder.

void QMdiArea::tileSubWindows ()   [slot]

Arranges all child windows in a tile pattern.

See also cascadeSubWindows() and arrangeMinimizedSubWindows().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.0-snapshot-20070202