The QMenuData class is a base class for QMenuBar and QPopupMenu. More...
#include <qmenudata.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 and text of the menu item id.
See also: pixmap().
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 a pointer to the menu item with identifier id, or 0 if there is no item with such an identifier, and changes parent to point to the parent of the return value.
See also: indexOf().
[protected]
Internal function that finds the menu item where popup is located, storing its index at index if index is not NULL.
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 popup must be deleted by the programmer. It is not deleted when this menu item is removed or when the menu is deleted. Note that all popups are automatically deleted when the application terminates. (The QApplication destructor destroys all remaining widgets.)
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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a menu item with a pixmap, an accelerator key, an id and an optional index and connects it to an object/slot.
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.
Note that accelerators only work for QPopupMenu items that live in a menu bar. For stand-alone popup menus, use an independent QAccel object.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Inserts a menu item with a pixmap and an optional accelerator key, and connects it to an object/slot.
Returns a unique menu item identifier (negative integer <= -2).
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Inserts a menu item with a pixmap, a text and a sub menu. Returns the menu item identifier.
The popup must be deleted by the programmer. It is not deleted when this menu item is removed or when the menu is deleted. Note that all popups are automatically deleted when the application terminates. (The QApplication destructor destroys all remaining widgets.)
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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a menu item with a pixmap, a text, an accelerator key, an id and an optional index and connects it to an object/slot.
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.
Note that accelerators only work for QPopupMenu items that live in a menu bar. For stand-alone popup menus, use an independent QAccel object.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Examples: qtimage/qtimage.cpp grapher/grapher.cpp xform/xform.cpp application/application.cpp menu/menu.cpp progress/progress.cpp layout/layout.cpp showimg/showimg.cpp widgets/widgets.cpp
Inserts a menu item with a pixmap, a text and an optional accelerator key, and connects it to an object/slot. The pixmap will be displayed to the left of the text in the item.
Returns a unique menu item identifier (negative integer <= -2).
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Inserts a menu item with a pixmap and 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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel() and connectItem().
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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a menu item with a text and a sub menu. Returns the menu item identifier.
The popup must be deleted by the programmer. It is not deleted when this menu item is removed or when the menu is deleted. Note that all popups are automatically deleted when the application terminates. (The QApplication destructor destroys all remaining widgets.)
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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a menu item with a text, an accelerator key, an id and an optional index and connects it to an object/slot.
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.
Note that accelerators only work for QPopupMenu items that live in a menu bar. For stand-alone popup menus, use an independent QAccel object.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qkeycode.h.
Inserts a menu item with a text and an 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->insertItem( "New", myView, SLOT(newFile()), CTRL+Key_N ); fileMenu->insertItem( "Open", myView, SLOT(open()), CTRL+Key_O ); mainMenu->insertItem( "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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
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.
Warning: Be careful when passing a literal 0 to insertItem(), as some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, eg. (QObject*)0.
See also: removeItem(), changeItem(), setAccel() and connectItem().
Inserts a separator at position index. The separator becomes the last menu item if index is negative.
In a popup menu, a separator is rendered as a horizontal line. In a Motif menubar, a separator is spacing, so the rest of the items (just "Help", normally) are drawn right-justified. In a Windows menubar, all separator are ignored (to comply with the Windows style guide).
Examples: grapher/grapher.cpp application/application.cpp menu/menu.cpp progress/progress.cpp widgets/widgets.cpp
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 the menu item with id id if check is TRUE, or unchecks it if check is FALSE, and calls setCheckable( TRUE ) if necessary.
See also: isItemChecked().
Examples: grapher/grapher.cpp progress/progress.cpp
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 progress/progress.cpp widgets/widgets.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.
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.
It was generated from the following files:
Copyright İ 1998 Troll Tech | Trademarks | Qt version 1.42
|