Home

QtWindowListMenu Class Reference

The QtWindowListMenu class is a menu that provides navigation commands for the subwindows in a QMdiArea. More...

 #include <QtWindowListMenu>

Inherits QMenu.

Public Types

Public Functions

Protected Slots

Additional Inherited Members


Detailed Description

The QtWindowListMenu class is a menu that provides navigation commands for the subwindows in a QMdiArea.

It is typically used as the conventional "Windows" item in an MDI application's menubar. It provides some standard commands for arranging and closing the MDI subwindows, corresponding to the slots of QMdiArea, as well as shortcuts to navigate directly to each of them.

Usage: After creation, use attachToMdiArea() to tell the QtWindowListMenu object which QMdiArea object it should provide navigation commands for. It can then be added to a QMenuBar (or other objects that can take QMenus or QActions, like QToolButton or QMenu) in the ordinary way, since QtWindowListMenu is a QMenu subclass.

The subwindow navigation items may be given a common icon with setDefaultIcon(). The item icon for a specific subwindow can be set with setWindowIcon().

Customization: Additional menu items (actions) can be inserted into this menu in the ordinary way for a QMenu. The standardAction() method gives access to the standard navigation items, which can be used to change their icon, shortcut, visibility etc. Ultimately, the whole menu can be customized by overriding syncWithMdiArea() in a subclass of QtWindowListMenu.

If a QtWindowListMenu is showed and opened before being attached to a QMdiArea, it will try to auto-attach itself to the closest sibling object that is or inherits QMdiArea, if any exists. This behaviour is intended for special usecases; normally you will want to explicitly specify the desired QMdiArea with attachToMdiArea().

See also QMdiArea, QMdiSubWindow, QMenuBar, and QAction.


Member Type Documentation

enum QtWindowListMenu::StandardAction

This enum specifies the standard menu items of a QtWindowListMenu.

ConstantValueDescription
QtWindowListMenu::CloseAction0Ref. QMdiArea::closeActiveSubWindow()
QtWindowListMenu::CloseAllAction1Ref. QMdiArea::closeAllSubWindows()
QtWindowListMenu::TileAction3Ref. QMdiArea::tileSubWindows()
QtWindowListMenu::CascadeAction4Ref. QMdiArea::cascadeSubWindows()
QtWindowListMenu::NextAction6Ref. QMdiArea::activateNextSubWindow()
QtWindowListMenu::PrevAction7Ref. QMdiArea::activatePreviousSubWindow()

See also standardAction().


Member Function Documentation

QtWindowListMenu::QtWindowListMenu ( QWidget * parent = 0 )

Constructs a QtWindowListMenu object. The parent parameter is passed to the QMenu constructor. Although this parameter has the conventional default of 0, you will normally want to explicitly provide a parent object, since the later adding of this menu object to an action container (e.g. QMenuBar) does not cause a reparenting. The container is normally the natural choice for parent.

void QtWindowListMenu::activateWindow ( QAction * act )   [protected slot]

This slot is executed when the user selects one of the subwindow navigation actions, given in act. It causes the corresponding subwindow in the attached QMdiArea object to be activated.

void QtWindowListMenu::attachToMdiArea ( QMdiArea * mdiArea )   [virtual]

Instructs this menu to display navigation actions for the QMdiArea mdiArea. This should be done before this menu is shown.

Specifying a 0 mdiArea is meaningless and will generate a warning.

For special usecases, see the note about auto-attachment in the class description.

QMdiArea * QtWindowListMenu::attachedMdiArea () const

Returns the QMdiArea this menu is currently attached to, or 0 if not yet attached.

See also attachToMdiArea().

QIcon QtWindowListMenu::defaultIcon () const

Returns the default icon for the subwindow navigation items in this QtWindowListMenu. This will be a null icon if none has been explicitly set.

See also setDefaultIcon().

void QtWindowListMenu::setDefaultIcon ( const QIcon & icon )

Sets icon as the default icon for the subwindow navigation items in this QtWindowListMenu. If icon is a null icon, then the default icon will be cleared.

See also defaultIcon().

void QtWindowListMenu::setWindowIcon ( const QMdiSubWindow * window, const QIcon & icon )

Sets icon as the icon of the menu item corresponding to the mdi subwindow window. If icon is a null icon, the current item icon will be cleared.

See also windowIcon().

QAction * QtWindowListMenu::standardAction ( StandardAction item ) const

Returns a pointer to the standard navigation action of this menu specified by item. This can be used to customize the look, shortcut, tool tip, etc. of this item, or to provide alternative access to it through a tool button etc.

The returned object is owned by this QtWindowListMenu, and must not be deleted. If you want QtWindowListMenu to not display this action, set its "visible" property to false.

void QtWindowListMenu::syncWithMdiArea ()   [virtual protected slot]

This slot is executed immediately prior to each opening of this menu. It removes the previous subwindow navigation actions and adds new ones according to the current state of the attached QMdiArea.

void QtWindowListMenu::windowDestroyed ( QObject * obj )   [protected slot]

This slot is executed whenever a subwindow (obj) of the attached QMdiArea, for which an icon has been, is deleted. It clears that icon.

QIcon QtWindowListMenu::windowIcon ( const QMdiSubWindow * window ) const

Returns the icon of the menu item corresponding to the mdi subwindow window. This will be a null icon if none has been explicitly set.

See also setWindowIcon().


Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt Solutions