Home · Overviews · Examples 

QMdiArea Class Reference
[com.trolltech.qt.gui module]

The QMdiArea widget provides an area in which MDI windows are displayed. More...

Inherits QAbstractScrollArea.


Detailed Description

The QMdiArea widget provides an area in which MDI windows are displayed.

QMdiArea functions, essentially, like a window manager for MDI windows. For instance, it draws the windows it manages on itself and arranges them in a cascading or tile pattern. QMdiArea is commonly used as the center widget in a QMainWindow to create MDI applications, but can also be placed in any layout. The following code adds an area to a main window:

        QMainWindow *mainWindow = new QMainWindow;
        mainWindow->setCentralWidget(mdiArea);

Unlike the window managers for top-level windows, all window flags (Qt::WindowFlags) are supported by QMdiArea as long as the flags are supported by the current widget style. If a specific flag is not supported by the style (e.g., the WindowShadeButtonHint), you can still shade the window with showShaded().

Subwindows in QMdiArea are instances of QMdiSubWindow. They are added to an MDI area with addSubWindow. It is common to pass a QWidget, which is set as the internal widget, to this function, but it is also possible to pass a QMdiSubWindow directly.The class inherits QWidget, and you can use the same API as with a normal top-level window when programming. QMdiSubWindow also has behavior that is specific to MDI windows. See the QMdiSubWindow class description for more details.

A subwindow becomes active when it gets the keyboard focus, or when setFocus is called. The user activates a window by moving focus in the usual ways. The MDI area emits the subWindowActivated signal when the active window changes, and the activeSubWindow function returns the active subwindow.

The convenience function subWindowList returns a list of all subwindows. This information could be used in a popup menu containing a list of windows, for example.

QMdiArea provides two built-in layout strategies for subwindows: cascadeSubWindows and tileSubWindows. Both are slots and are easily connected to menu entries.

Note: The default scroll bar property for QMdiArea is Qt::ScrollBarAlwaysOff.

See also QMdiSubWindow.


Copyright © 2008 Trolltech Trademarks
Qt Jambi 4.3.4_01