The QMenuData class is a base class for QMenuBar and QPopupMenu. More...
#include <qmenudta.h>
Inherited by QMenuBar and QPopupMenu.
QMenuData has an internal list of menu items. A menu item is a text, pixmap or a separator, and may also have a popup menu (separators have no popup menus).
The menu item sends out an activated() signal when it is selected, and a highlighted() signal when it receives the user input focus.
Menu items can be accessed through identifiers.
See also: QAccel.
Constructs an empty list.
[virtual]
Removes all menu items and disconnects any signals that have been connected.
Returns the accelerator key that has been defined for the menu item id, or 0 if it has no accelerator key.
See also: setAccel(), QAccel and qkeycode.h.
Changes the pixmap of the menu item id.
See also: pixmap().
Changes the text of the menu item id.
See also: text().
Removes all menu items.
See also: removeItem() and removeItemAt().
Connects a menu item to a receiver and a slot or signal.
The receiver's slot/signal is activated when the menu item is activated.
Returns the number of items in the menu.
Disconnects a receiver/member from a menu item.
All connections are removed when the menu data object is destroyed.
Returns a pointer to the menu item with identifier id, or 0 if there is no item with such an identifier.
See also: indexOf().
Returns the identifier of the menu item at position index in the internal list, or -1 if index is out of range.
See also: setId() and indexOf().
Returns the index of the menu item with identifier id, or -1 if there is no item with such an identifier.
See also: idAt() and findItem().
Inserts a menu item with a pixmap and a sub menu. Returns the menu item identifier.
The menu item is assigned the identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is set equal to the menu item's real index (see below). If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated.
The index specifies the position in the menu. The menu item is appended at the end of the list if index is negative.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a menu item with a pixmap and optional accelerator key, and connects it to an object/slot.
Returns a unique menu item identifier (negative integer <= -2).
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Inserts a menu item with a pixmap. Returns the menu item identifier.
The menu item is assigned the identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is set equal to the menu item's real index (see below). If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated.
The index specifies the position in the menu. The menu item is appended at the end of the list if index is negative.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Examples: menu/menu.cpp
Inserts a menu item with a text and a sub menu. Returns the menu item identifier.
The menu item is assigned the identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is set equal to the menu item's real index (see below). If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated.
The index specifies the position in the menu. The menu item is appended at the end of the list if index is negative.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a menu item with a text and optional accelerator key, and connects it to an object/slot.
Returns a unique menu item identifier (negative integer <= -2).
Example:
QMenuBar *mainMenu = new QMenuBar; QPopupMenu *fileMenu = new QPopupMenu; fileMenu->insert( "New", myView, SLOT(newFile()), CTRL+Key_N ); fileMenu->insert( "Open", myView, SLOT(open()), CTRL+Key_O ); mainMenu->insert( "File", fileMenu );
In the example above, pressing CTRL+N or selecting "open" from the menu activates the myView->open() function.
Note that accelerators only work for QPopupMenu items that live in a menu bar. For stand-alone popup menus, use an independent QAccel object.
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Inserts a menu item with a text. Returns the menu item identifier.
The menu item is assigned the identifier id or an automatically generated identifier. It works as follows: If id >= 0, this identifier is assigned. If id == -1 (default), the identifier is set equal to the menu item's real index (see below). If id is any other negative integer, for instance -2, a unique identifier (negative integer <= -2) is generated.
The index specifies the position in the menu. The menu item is appended at the end of the list if index is negative.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a separator at position index. The separator becomes the last menu item if index is negative.
Returns TRUE if the menu item has been checked, otherwise FALSE.
See also: setItemChecked().
Returns TRUE if the item with identifier id is enabled or FALSE if it is disabled.
See also: setItemEnabled().
[virtual protected]
Virtual function; notifies subclasses that one or more items have been inserted or removed.
Reimplemented in QMenuBar.
[virtual protected]
Virtual function; notifies subclasses that a popup menu item has been removed.
[virtual protected]
Virtual function; notifies subclasses that a popup menu item has been inserted.
[virtual protected]
Virtual function; notifies subclasses that one or more items have changed state (enabled/disabled or checked/unchecked).
Reimplemented in QMenuBar.
Returns the pixmap that has been set for menu item id, or 0 if no pixmap has been set.
See also: changeItem() and text().
Removes the menu item which has the identifier id.
See also: removeItemAt() and clear().
Removes the menu item at position index.
See also: removeItem() and clear().
Defines an accelerator key for the menu item id.
An accelerator key consists of a key code and a combination of the modifiers
SHIFT, CTRL
and ALT
(OR'ed or added).
The header file qkeycode.h contains a list of key codes.
Defining an accelerator key generates a text which is added to the
menu item, for instance, CTRL
+ Key_O
generates "Ctrl+O". The
text is formatted differently for different platforms.
Note that accelerators only work for QPopupMenu items that live in a menu bar. For stand-alone popup menus, use an independent QAccel object.
Example:
QMenuBar *mainMenu = new QMenuBar; QPopupMenu *fileMenu = new QPopupMenu; // file sub menu fileMenu->insertItem( "Open Document", 67 );// add "Open" item fileMenu->setAccel( CTRL + Key_O, 67 ); fileMenu->insertItem( "Quit", 69 ); // add "Quit" item fileMenu->setAccel( CTRL + ALT + Key_Delete, 69 ); mainMenu->insertItem( "File", fileMenu ); // add the file menu
You can also specify the accelerator in the insertItem() function.
See also: accel(), insertItem(), QAccel and qkeycode.h.
Sets the menu identifier of the item at index to id.
If index is out of range the operation is ignored.
See also: idAt().
Checks a menu item if check is TRUE, or unchecks it if check is FALSE.
See also: isItemChecked().
Enables the menu item with identifier id if enable is TRUE, or disables the item if enable is FALSE.
See also: isItemEnabled().
Examples: menu/menu.cpp
Returns the text that has been set for menu item id, or 0 if no text has been set.
See also: changeItem() and pixmap().
[virtual]
Virtual function; notifies subclasses about an item that has been changed.
Reimplemented in QMenuBar.
This file is part of the Qt toolkit, copyright © 1995-96 Troll Tech, all rights reserved.
It was generated from the following files: