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 qnamespace.h.
This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.
Changes the icon and text of the menu item id.
See also: pixmap().
This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.
Changes the pixmap of the menu item id. If the item has an icon, the icon remains unchanged.
See also: pixmap().
This function is obsolete. It is provided to keep old programs working. We strongly advise against using it in new code.
Changes the text of the menu item id. If the item has an icon, the icon remains unchanged.
See also: text().
Changes the icon and pixmap of the menu item id.
See also: pixmap().
Changes the icon and text of the menu item id.
See also: pixmap().
Changes the pixmap of the menu item id. If the item has an icon, the icon remains unchanged.
See also: pixmap().
Changes the text of the menu item id. If the item has an icon, the icon remains unchanged.
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 icon set that has been set for menu item id, or 0 if no icon set has been set.
See also: changeItem(), text() and pixmap().
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().
Examples: scrollview/scrollview.cpp
Inserts a menu item with an icon, a pixmap and a sub menu. The icon will be displayed to the left of the pixmap in the item. Returns the menu item identifier.
The popup must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 an icon, a pixmap, an accelerator key, an id and an optional index and connects it to an object/slot. The icon will be displayed to the left of the pixmap in the item.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 qnamespace.h.
Inserts a menu item with an icon and a pixmap. The icon will be displayed to the left of the pixmap in the item. Returns the menu item identifier.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 an icon, a text and a sub menu. The icon will be displayed to the left of the text in the item. Returns the menu item identifier.
The popup must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 an icon, a text, an accelerator key, an id and an optional index and connects it to an object/slot. The icon will be displayed to the left of the text in the item.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 qnamespace.h.
Inserts a menu item with an icon and a text. The icon will be displayed to the left of the text in the item. Returns the menu item identifier.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 and a sub menu. The icon will be displayed to the left of the pixmap in the item. Returns the menu item identifier.
The popup must be deleted by the programmer or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 qnamespace.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 if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 or by its parent widget. It is not deleted when this menu item is removed or when the menu is deleted.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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().
Examples: qtimage/qtimage.cpp grapher/grapher.cpp mainlyQt/editor.cpp layout/layout.cpp menu/menu.cpp progress/progress.cpp scrollview/scrollview.cpp
Inserts a menu item with a text, an accelerator key, an id and an optional index and connects it to an object/slot.
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 );
If you will need to translate accelerators, use QAccel::stringToKey() to calculate the accelerator key:
fileMenu->insertItem( tr("Open"), myView, SLOT(open()), QAccel::stringToKey( tr("Ctrl+O") ) );
In the example above, pressing CTRL+N or selecting "open" from the menu activates the myView->open() function.
The menu item is assigned the identifier id or an automatically generated identifier if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 qnamespace.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 if id is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application.
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 menu/menu.cpp progress/progress.cpp scrollview/scrollview.cpp
Returns TRUE if the menu item has been checked, otherwise FALSE.
See also: setItemChecked().
Examples: progress/progress.cpp
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(), text() and iconSet().
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, ALT,
or UNICODE_ACCEL
(OR'ed or added).
The header file qnamespace.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 ); // Control and O to open fileMenu->insertItem( "Quit", 69 ); // add "Quit" item fileMenu->setAccel( CTRL + ALT + Key_Delete, 69 ); mainMenu->insertItem( "File", fileMenu ); // add the file menu
If you will need to translate accelerators, use QAccel::stringToKey():
fileMenu->setAccel( QAccel::stringToKey(tr("Ctrl+O")), 67 );
You can also specify the accelerator in the insertItem() function.
See also: setAccel(), accel(), insertItem(), QAccel and qnamespace.h.
[virtual]
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 scrollview/scrollview.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
Sets a Whats This help for a certain menu item.
Arguments:
See also: whatsThis().
Returns the text that has been set for menu item id, or a null string if no text has been set.
See also: changeItem(), pixmap() and iconSet().
[virtual]
Virtual function; notifies subclasses about an item that has been changed.
Reimplemented in QMenuBar.
Returns the Whats This help text for the specified item id or QString::null if no text has been defined yet.
See also: setWhatsThis().
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.
Copyright İ 1999 Troll Tech | Trademarks | Qt version 2.0.2
|