<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/widgets/qmenudata.cpp:61 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QMenuData Class</title> <style type="text/css"><!-- h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QMenuData Class Reference</h1> <p>The QMenuData class is a base class for QMenuBar and QPopupMenu. <a href="#details">More...</a> <p><tt>#include <<a href="qmenudata-h.html">qmenudata.h</a>></tt> <p>Inherited by <a href="qmenubar.html">QMenuBar</a> and <a href="qpopupmenu.html">QPopupMenu</a>. <p><a href="qmenudata-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li><div class=fn><a href="#QMenuData"><b>QMenuData</b></a> ()</div></li> <li><div class=fn>virtual <a href="#~QMenuData"><b>~QMenuData</b></a> ()</div></li> <li><div class=fn>uint <a href="#count"><b>count</b></a> () const</div></li> <li><div class=fn>int <a href="#insertItem"><b>insertItem</b></a> ( const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-2"><b>insertItem</b></a> ( const QIconSet & icon, const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-3"><b>insertItem</b></a> ( const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-4"><b>insertItem</b></a> ( const QIconSet & icon, const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-5"><b>insertItem</b></a> ( const QString & text, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-6"><b>insertItem</b></a> ( const QIconSet & icon, const QString & text, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-7"><b>insertItem</b></a> ( const QString & text, QPopupMenu * popup, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-8"><b>insertItem</b></a> ( const QIconSet & icon, const QString & text, QPopupMenu * popup, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-9"><b>insertItem</b></a> ( const QPixmap & pixmap, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-a"><b>insertItem</b></a> ( const QIconSet & icon, const QPixmap & pixmap, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-b"><b>insertItem</b></a> ( const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-c"><b>insertItem</b></a> ( const QIconSet & icon, const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-d"><b>insertItem</b></a> ( QWidget * widget, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-e"><b>insertItem</b></a> ( const QIconSet & icon, QCustomMenuItem * custom, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertItem-f"><b>insertItem</b></a> ( QCustomMenuItem * custom, int id = -1, int index = -1 )</div></li> <li><div class=fn>int <a href="#insertSeparator"><b>insertSeparator</b></a> ( int index = -1 )</div></li> <li><div class=fn>void <a href="#removeItem"><b>removeItem</b></a> ( int id )</div></li> <li><div class=fn>void <a href="#removeItemAt"><b>removeItemAt</b></a> ( int index )</div></li> <li><div class=fn>void <a href="#clear"><b>clear</b></a> ()</div></li> <li><div class=fn>QKeySequence <a href="#accel"><b>accel</b></a> ( int id ) const</div></li> <li><div class=fn>void <a href="#setAccel"><b>setAccel</b></a> ( const QKeySequence & key, int id )</div></li> <li><div class=fn>QIconSet * <a href="#iconSet"><b>iconSet</b></a> ( int id ) const</div></li> <li><div class=fn>QString <a href="#text"><b>text</b></a> ( int id ) const</div></li> <li><div class=fn>QPixmap * <a href="#pixmap"><b>pixmap</b></a> ( int id ) const</div></li> <li><div class=fn>void <a href="#setWhatsThis"><b>setWhatsThis</b></a> ( int id, const QString & text )</div></li> <li><div class=fn>QString <a href="#whatsThis"><b>whatsThis</b></a> ( int id ) const</div></li> <li><div class=fn>void <a href="#changeItem"><b>changeItem</b></a> ( int id, const QString & text )</div></li> <li><div class=fn>void <a href="#changeItem-2"><b>changeItem</b></a> ( int id, const QPixmap & pixmap )</div></li> <li><div class=fn>void <a href="#changeItem-3"><b>changeItem</b></a> ( int id, const QIconSet & icon, const QString & text )</div></li> <li><div class=fn>void <a href="#changeItem-4"><b>changeItem</b></a> ( int id, const QIconSet & icon, const QPixmap & pixmap )</div></li> <li><div class=fn>void changeItem ( const QString & text, int id ) <em>(obsolete)</em></div></li> <li><div class=fn>void changeItem ( const QPixmap & pixmap, int id ) <em>(obsolete)</em></div></li> <li><div class=fn>void changeItem ( const QIconSet & icon, const QString & text, int id ) <em>(obsolete)</em></div></li> <li><div class=fn>bool <a href="#isItemActive"><b>isItemActive</b></a> ( int id ) const</div></li> <li><div class=fn>bool <a href="#isItemEnabled"><b>isItemEnabled</b></a> ( int id ) const</div></li> <li><div class=fn>void <a href="#setItemEnabled"><b>setItemEnabled</b></a> ( int id, bool enable )</div></li> <li><div class=fn>bool <a href="#isItemChecked"><b>isItemChecked</b></a> ( int id ) const</div></li> <li><div class=fn>void <a href="#setItemChecked"><b>setItemChecked</b></a> ( int id, bool check )</div></li> <li><div class=fn>virtual void <a href="#updateItem"><b>updateItem</b></a> ( int id )</div></li> <li><div class=fn>int <a href="#indexOf"><b>indexOf</b></a> ( int id ) const</div></li> <li><div class=fn>int <a href="#idAt"><b>idAt</b></a> ( int index ) const</div></li> <li><div class=fn>virtual void <a href="#setId"><b>setId</b></a> ( int index, int id )</div></li> <li><div class=fn>bool <a href="#connectItem"><b>connectItem</b></a> ( int id, const QObject * receiver, const char * member )</div></li> <li><div class=fn>bool <a href="#disconnectItem"><b>disconnectItem</b></a> ( int id, const QObject * receiver, const char * member )</div></li> <li><div class=fn>bool <a href="#setItemParameter"><b>setItemParameter</b></a> ( int id, int param )</div></li> <li><div class=fn>int <a href="#itemParameter"><b>itemParameter</b></a> ( int id ) const</div></li> <li><div class=fn>QMenuItem * <a href="#findItem"><b>findItem</b></a> ( int id ) const</div></li> <li><div class=fn>QMenuItem * <a href="#findItem-2"><b>findItem</b></a> ( int id, QMenuData ** parent ) const</div></li> <li><div class=fn>virtual void <a href="#activateItemAt"><b>activateItemAt</b></a> ( int index )</div></li> </ul> <h2>Protected Members</h2> <ul> <li><div class=fn>virtual void <a href="#menuContentsChanged"><b>menuContentsChanged</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#menuStateChanged"><b>menuStateChanged</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#menuInsPopup"><b>menuInsPopup</b></a> ( QPopupMenu * )</div></li> <li><div class=fn>virtual void <a href="#menuDelPopup"><b>menuDelPopup</b></a> ( QPopupMenu * )</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QMenuData class is a base class for <a href="qmenubar.html">QMenuBar</a> and <a href="qpopupmenu.html">QPopupMenu</a>. <p> <p> QMenuData has an internal list of menu items. A menu item is a text, pixmap or separator, and may also have a popup menu (separators have no popup menus). <p> The menu item sends out an <a href="qmenubar.html#activated">activated()</a> signal when it is selected and a <a href="qmenubar.html#highlighted">highlighted()</a> signal when it receives the user input focus. <p> <!-- index menu identifier --><a name="menu-identifier"></a> <p> Menu items are assigned the menu identifier <em>id</em> that is passed in <a href="#insertItem">insertItem</a>() or an automatically generated identifier if <em>id</em> is < 0 (the default). The generated identifiers (negative integers) are guaranteed to be unique within the entire application. The identifier is used to access the menu item in other functions. <p> Menu items can be removed with <a href="#removeItem">removeItem</a>() or changed with <a href="#changeItem">changeItem</a>(). Accelerators can be changed or set with <a href="#setAccel">setAccel</a>(). Checkable items can be checked or unchecked with <a href="#setItemChecked">setItemChecked</a>(). Items can be enabled or disabled using <a href="#setItemEnabled">setItemEnabled</a>() and connected and disconnected with <a href="#connectItem">connectItem</a>() and <a href="#disconnectItem">disconnectItem</a>() respectively. <p> Menu items are stored in a list. Use <a href="#findItem">findItem</a>() to find an item by its list position or by its menu identifier. <p> <p>See also <a href="qaccel.html">QAccel</a>, <a href="qpopupmenu.html">QPopupMenu</a>, <a href="qaction.html">QAction</a> and <a href="misc.html">Miscellaneous Classes</a>. <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QMenuData"></a>QMenuData::QMenuData () </h3> Constructs an empty menu data list. <h3 class=fn><a name="~QMenuData"></a>QMenuData::~QMenuData ()<tt> [virtual]</tt> </h3> Removes all menu items and disconnects any signals that have been connected. <h3 class=fn><a href="qkeysequence.html">QKeySequence</a> <a name="accel"></a>QMenuData::accel ( int id ) const </h3> Returns the accelerator key that has been defined for the menu item <em>id</em>, or 0 if it has no accelerator key. <p> <p>See also <a href="#setAccel">setAccel</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>. <h3 class=fn>void <a name="activateItemAt"></a>QMenuData::activateItemAt ( int index )<tt> [virtual]</tt> </h3> Activates the menu item at position <em>index</em>. <p> If the index is invalid (for example, -1), the object itself is deactivated. <h3 class=fn>void <a name="changeItem"></a>QMenuData::changeItem ( int id, const <a href="qstring.html">QString</a> & text ) </h3> Changes the text of the menu item <em>id</em> to <em>text</em>. If the item has an icon, the icon remains unchanged. <p>See also <a href="#text">text</a>(). <h3 class=fn>void <a name="changeItem-2"></a>QMenuData::changeItem ( int id, const <a href="qpixmap.html">QPixmap</a> & pixmap ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Changes the pixmap of the menu item <em>id</em> to the pixmap <em>pixmap</em>. If the item has an icon, the icon is unchanged. <p>See also <a href="#pixmap">pixmap</a>(). <h3 class=fn>void <a name="changeItem-3"></a>QMenuData::changeItem ( int id, const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & text ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Changes the iconset and text of the menu item <em>id</em> to the <em>icon</em> and <em>text</em> respectively. <p>See also <a href="#pixmap">pixmap</a>(). <h3 class=fn>void <a name="changeItem-4"></a>QMenuData::changeItem ( int id, const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qpixmap.html">QPixmap</a> & pixmap ) </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Changes the iconset and pixmap of the menu item <em>id</em> to <em>icon</em> and <em>pixmap</em> respectively. <p>See also <a href="#pixmap">pixmap</a>(). <h3 class=fn>void <a name="changeItem-5"></a>QMenuData::changeItem ( const <a href="qstring.html">QString</a> & text, int id ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Changes the text of the menu item <em>id</em>. If the item has an icon, the icon remains unchanged. <p> <p>See also <a href="#text">text</a>(). <h3 class=fn>void <a name="changeItem-6"></a>QMenuData::changeItem ( const <a href="qpixmap.html">QPixmap</a> & pixmap, int id ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Changes the pixmap of the menu item <em>id</em>. If the item has an icon, the icon remains unchanged. <p> <p>See also <a href="#pixmap">pixmap</a>(). <h3 class=fn>void <a name="changeItem-7"></a>QMenuData::changeItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & text, int id ) </h3> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code. <p> Changes the icon and text of the menu item <em>id</em>. <p> <p>See also <a href="#pixmap">pixmap</a>(). <h3 class=fn>void <a name="clear"></a>QMenuData::clear () </h3> Removes all menu items. <p> <p>See also <a href="#removeItem">removeItem</a>() and <a href="#removeItemAt">removeItemAt</a>(). <p>Examples: <a href="mdi-example.html#x1147">mdi/application.cpp</a> and <a href="qwerty-example.html#x632">qwerty/qwerty.cpp</a>. <h3 class=fn>bool <a name="connectItem"></a>QMenuData::connectItem ( int id, const <a href="qobject.html">QObject</a> * receiver, const char * member ) </h3> Connects the menu item with identifier <em>id</em> to <em>receiver</em>'s <em>member</em> slot or signal. <p> The receiver's slot/signal is activated when the menu item is activated. <p> <p>See also <a href="#disconnectItem">disconnectItem</a>() and <a href="#setItemParameter">setItemParameter</a>(). <p>Example: <a href="menu-example.html#x1122">menu/menu.cpp</a>. <h3 class=fn>uint <a name="count"></a>QMenuData::count () const </h3> Returns the number of items in the menu. <h3 class=fn>bool <a name="disconnectItem"></a>QMenuData::disconnectItem ( int id, const <a href="qobject.html">QObject</a> * receiver, const char * member ) </h3> Disconnects the <em>receiver</em>'s <em>member</em> from the menu item with identifier <em>id</em>. <p> All connections are removed when the menu data object is destroyed. <p> <p>See also <a href="#connectItem">connectItem</a>() and <a href="#setItemParameter">setItemParameter</a>(). <h3 class=fn>QMenuItem * <a name="findItem"></a>QMenuData::findItem ( int id ) const </h3> Returns a pointer to the menu item with identifier <em>id</em>, or 0 if there is no item with this identifier. <p>See also <a href="#indexOf">indexOf</a>(). <h3 class=fn>QMenuItem * <a name="findItem-2"></a>QMenuData::findItem ( int id, <a href="qmenudata.html">QMenuData</a> ** parent ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns a pointer to the menu item with identifier <em>id</em>, or 0 if there is no item with this identifier. Changes <em>*</em><em>parent</em> to point to the parent of the return value. <p> <p>See also <a href="#indexOf">indexOf</a>(). <h3 class=fn><a href="qiconset.html">QIconSet</a> * <a name="iconSet"></a>QMenuData::iconSet ( int id ) const </h3> Returns the icon set that has been set for menu item <em>id</em>, or 0 if no icon set has been set. <p>See also <a href="#changeItem">changeItem</a>(), <a href="#text">text</a>() and <a href="#pixmap">pixmap</a>(). <h3 class=fn>int <a name="idAt"></a>QMenuData::idAt ( int index ) const </h3> Returns the identifier of the menu item at position <em>index</em> in the internal list, or -1 if <em>index</em> is out of range. <p>See also <a href="#setId">setId</a>() and <a href="#indexOf">indexOf</a>(). <h3 class=fn>int <a name="indexOf"></a>QMenuData::indexOf ( int id ) const </h3> Returns the index of the menu item with identifier <em>id</em>, or -1 if there is no item with this identifier. <p>See also <a href="#idAt">idAt</a>() and <a href="#findItem">findItem</a>(). <p>Example: <a href="scrollview-example.html#x486">scrollview/scrollview.cpp</a>. <h3 class=fn>int <a name="insertItem"></a>QMenuData::insertItem ( const <a href="qstring.html">QString</a> & text, const <a href="qobject.html">QObject</a> * receiver, const char * member, const <a href="qkeysequence.html">QKeySequence</a> & accel = 0, int id = -1, int index = -1 ) </h3> The family of <a href="#insertItem">insertItem</a>() functions inserts menu items into a popup menu or a menu bar. <p> A menu item is usually either a text string or a pixmap, both with an optional icon or keyboard accelerator. For special cases it is also possible to insert custom items (see <a href="qcustommenuitem.html">QCustomMenuItem</a>) or even widgets into popup menus. <p> Some insertItem() members take a popup menu as an additional argument. Use this to insert submenus to existing menus or pulldown menus to a menu bar. <p> The number of insert functions may look confusing, but they are actually quite simple to use. <p> This default version inserts a menu item with the text <em>text</em>, the accelerator key <em>accel</em>, an id and an optional index and connects it to the slot <em>member</em> in the object <em>receiver</em>. <p> Example: <pre> <a href="qmenubar.html">QMenuBar</a> *mainMenu = new <a href="qmenubar.html">QMenuBar</a>; <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu = new <a href="qpopupmenu.html">QPopupMenu</a>; fileMenu-><a href="#insertItem">insertItem</a>( "New", myView, SLOT(newFile()), CTRL+Key_N ); fileMenu-><a href="#insertItem">insertItem</a>( "Open", myView, SLOT(open()), CTRL+Key_O ); mainMenu-><a href="#insertItem">insertItem</a>( "File", fileMenu ); </pre> <p> Not all insert functions take an object/slot parameter or an accelerator key. Use <a href="#connectItem">connectItem</a>() and <a href="#setAccel">setAccel</a>() on these items. <p> If you need to translate accelerators, use tr() with a string description that use pass to the <a href="qkeysequence.html">QKeySequence</a> constructor: <pre> fileMenu->insertItem( tr("Open"), myView, SLOT(open()), tr("Ctrl+O") ); </pre> <p> In the example above, pressing Ctrl+N or selecting "Open" from the menu activates the myView->open() function. <p> Some insert functions take a <a href="qiconset.html">QIconSet</a> parameter to specify the little menu item icon. Note that you can always pass a <a href="qpixmap.html">QPixmap</a> object instead. <p> The <em>index</em> specifies the position in the menu. The menu item is appended at the end of the list if <em>index</em> is negative. <p> Note that keyboard accelerators in Qt are not application-global, instead they are bound to a certain top-level window. For example, accelerators in <a href="qpopupmenu.html">QPopupMenu</a> items only work for menus that are associated with a certain window. This is true for popup menus that live in a menu bar since their accelerators will then be installed in the menu bar itself. This also applies to stand-alone popup menus that have a top-level widget in their parentWidget() chain. The menu will then install its accelerator object on that top-level widget. For all other cases use an independent <a href="qaccel.html">QAccel</a> object. <p> <b>Warning:</b> Be careful when passing a literal 0 to <a href="#insertItem">insertItem</a>() because some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, e.g. <tt>(QObject*)0</tt>. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), <a href="#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>. <p>Examples: <a href="addressbook-example.html#x1960">addressbook/mainwindow.cpp</a>, <a href="canvas-example.html#x2536">canvas/canvas.cpp</a>, <a href="mdi-example.html#x1148">mdi/application.cpp</a>, <a href="menu-example.html#x1123">menu/menu.cpp</a>, <a href="qwerty-example.html#x633">qwerty/qwerty.cpp</a>, <a href="scrollview-example.html#x487">scrollview/scrollview.cpp</a> and <a href="showimg-example.html#x427">showimg/showimg.cpp</a>. <h3 class=fn>int <a name="insertItem-2"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & text, const <a href="qobject.html">QObject</a> * receiver, const char * member, const <a href="qkeysequence.html">QKeySequence</a> & accel = 0, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, accelerator <em>accel</em>, optional id <em>id</em>, and optional <em>index</em>. The menu item is connected it to the <em>receiver</em>'s <em>member</em> slot. The icon will be displayed to the left of the text in the item. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), <a href="#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>. <h3 class=fn>int <a name="insertItem-3"></a>QMenuData::insertItem ( const <a href="qpixmap.html">QPixmap</a> & pixmap, const <a href="qobject.html">QObject</a> * receiver, const char * member, const <a href="qkeysequence.html">QKeySequence</a> & accel = 0, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with pixmap <em>pixmap</em>, accelerator <em>accel</em>, optional id <em>id</em>, and optional <em>index</em>. The menu item is connected it to the <em>receiver</em>'s <em>member</em> slot. The icon will be displayed to the left of the text in the item. <p> To look best when being highlighted as a menu item, the pixmap should provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()). <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-4"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qpixmap.html">QPixmap</a> & pixmap, const <a href="qobject.html">QObject</a> * receiver, const char * member, const <a href="qkeysequence.html">QKeySequence</a> & accel = 0, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>, accelerator <em>accel</em>, optional id <em>id</em>, and optional <em>index</em>. The icon will be displayed to the left of the pixmap in the item. The item is connected to the <em>member</em> slot in the <em>receiver</em> object. <p> To look best when being highlighted as a menu item, the pixmap should provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()). <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>(), <a href="#connectItem">connectItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qnamespace-h.html">qnamespace.h</a>. <h3 class=fn>int <a name="insertItem-5"></a>QMenuData::insertItem ( const <a href="qstring.html">QString</a> & text, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with text <em>text</em>, optional id <em>id</em>, and optional <em>index</em>. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-6"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & text, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, optional id <em>id</em>, and optional <em>index</em>. The icon will be displayed to the left of the text in the item. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-7"></a>QMenuData::insertItem ( const <a href="qstring.html">QString</a> & text, <a href="qpopupmenu.html">QPopupMenu</a> * popup, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with text <em>text</em>, submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em>. <p> The <em>popup</em> 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. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-8"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qstring.html">QString</a> & text, <a href="qpopupmenu.html">QPopupMenu</a> * popup, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with icon <em>icon</em>, text <em>text</em>, submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em>. The icon will be displayed to the left of the text in the item. <p> The <em>popup</em> 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. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-9"></a>QMenuData::insertItem ( const <a href="qpixmap.html">QPixmap</a> & pixmap, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with pixmap <em>pixmap</em>, optional id <em>id</em>, and optional <em>index</em>. <p> To look best when being highlighted as a menu item, the pixmap should provide a mask (see <a href="qpixmap.html#mask">QPixmap::mask</a>()). <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-a"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qpixmap.html">QPixmap</a> & pixmap, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em>, optional id <em>id</em>, and optional <em>index</em>. The icon will be displayed to the left of the pixmap in the item. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-b"></a>QMenuData::insertItem ( const <a href="qpixmap.html">QPixmap</a> & pixmap, <a href="qpopupmenu.html">QPopupMenu</a> * popup, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with pixmap <em>pixmap</em>, submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em>. <p> The <em>popup</em> 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. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-c"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, const <a href="qpixmap.html">QPixmap</a> & pixmap, <a href="qpopupmenu.html">QPopupMenu</a> * popup, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item with icon <em>icon</em>, pixmap <em>pixmap</em> submenu <em>popup</em>, optional id <em>id</em>, and optional <em>index</em>. The icon will be displayed to the left of the pixmap in the item. <p> The <em>popup</em> 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. <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(), <a href="#changeItem">changeItem</a>(), <a href="#setAccel">setAccel</a>() and <a href="#connectItem">connectItem</a>(). <h3 class=fn>int <a name="insertItem-d"></a>QMenuData::insertItem ( <a href="qwidget.html">QWidget</a> * widget, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a menu item that consists of the widget <em>widget</em> with optional id <em>id</em>, and optional <em>index</em>. <p> Ownership of <em>widget</em> is transferred to the popup menu or to the menu bar. <p> Theoretically, any widget can be inserted into a popup menu. In practice, this only makes sense with certain widgets. <p> If a widget is not focus-enabled (see <a href="qwidget.html#isFocusEnabled">QWidget::isFocusEnabled</a>()), the menu treats it as a separator; this means that the item is not selectable and will never get focus. In this way you can, for example, simply insert a <a href="qlabel.html">QLabel</a> if you need a popup menu with a title. <p> If the widget is focus-enabled it will get focus when the user traverses the popup menu with the arrow keys. If the widget does not accept ArrowUp and ArrowDown in its key event handler, the focus will move back to the menu when the respective arrow key is hit one more time. This works with a <a href="qlineedit.html">QLineEdit</a>, for example. If the widget accepts the arrow key itself, it must also provide the possibility to put the focus back on the menu again by calling <a href="qwidget.html#focusNextPrevChild">QWidget::focusNextPrevChild</a>(). Futhermore, if the embedded widget closes the menu when the user made a selection, this can be done safely by calling <pre> if ( isVisible() && parentWidget() && parentWidget()->inherits("QPopupMenu") ) parentWidget()->close(); </pre> <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#removeItem">removeItem</a>(). <h3 class=fn>int <a name="insertItem-e"></a>QMenuData::insertItem ( const <a href="qiconset.html">QIconSet</a> & icon, <a href="qcustommenuitem.html">QCustomMenuItem</a> * custom, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a custom menu item <em>custom</em> with an <em>icon</em> and with optional id <em>id</em>, and optional <em>index</em>. <p> This only works with popup menus. It is not supported for menu bars. Ownership of <em>custom</em> is transferred to the popup menu. <p> If you want to connect a custom item to a certain slot, use <a href="#connectItem">connectItem</a>(). <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#removeItem">removeItem</a>() and <a href="qcustommenuitem.html">QCustomMenuItem</a>. <h3 class=fn>int <a name="insertItem-f"></a>QMenuData::insertItem ( <a href="qcustommenuitem.html">QCustomMenuItem</a> * custom, int id = -1, int index = -1 ) </h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Inserts a custom menu item <em>custom</em> with optional id <em>id</em>, and optional <em>index</em>. <p> This only works with popup menus. It is not supported for menu bars. Ownership of <em>custom</em> is transferred to the popup menu. <p> If you want to connect a custom item to a certain slot, use <a href="#connectItem">connectItem</a>(). <p> Returns the allocated <a href="qmenudata.html#menu-identifier">menu identifier</a> number (<em>id</em> if <em>id</em> >= 0). <p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#removeItem">removeItem</a>() and <a href="qcustommenuitem.html">QCustomMenuItem</a>. <h3 class=fn>int <a name="insertSeparator"></a>QMenuData::insertSeparator ( int index = -1 ) </h3> Inserts a separator at position <em>index</em>. The separator becomes the last menu item if <em>index</em> is negative. <p> In a popup menu a separator is rendered as a horizontal line. In a Motif menu bar a separator is spacing, so the rest of the items (normally just "Help") are drawn right-justified. In a Windows menu bar separators are ignored (to comply with the Windows style guidelines). <p>Examples: <a href="addressbook-example.html#x1961">addressbook/mainwindow.cpp</a>, <a href="mdi-example.html#x1149">mdi/application.cpp</a>, <a href="menu-example.html#x1124">menu/menu.cpp</a>, <a href="progress-example.html#x839">progress/progress.cpp</a>, <a href="scrollview-example.html#x488">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x428">showimg/showimg.cpp</a> and <a href="sound-example.html#x2482">sound/sound.cpp</a>. <h3 class=fn>bool <a name="isItemActive"></a>QMenuData::isItemActive ( int id ) const </h3> Returns TRUE if the menu item with the id <em>id</em> is currently active; otherwise returns FALSE. <h3 class=fn>bool <a name="isItemChecked"></a>QMenuData::isItemChecked ( int id ) const </h3> Returns TRUE if the menu item with the id <em>id</em> has been checked; otherwise returns FALSE. <p> <p>See also <a href="#setItemChecked">setItemChecked</a>(). <p>Examples: <a href="canvas-example.html#x2538">canvas/canvas.cpp</a>, <a href="progress-example.html#x840">progress/progress.cpp</a> and <a href="showimg-example.html#x429">showimg/showimg.cpp</a>. <h3 class=fn>bool <a name="isItemEnabled"></a>QMenuData::isItemEnabled ( int id ) const </h3> Returns TRUE if the item with identifier <em>id</em> is enabled; otherwise returns FALSE <p>See also <a href="#setItemEnabled">setItemEnabled</a>(). <h3 class=fn>int <a name="itemParameter"></a>QMenuData::itemParameter ( int id ) const </h3> Returns the parameter of the activation signal of item <em>id</em>. <p> If no parameter has been specified for this item with <a href="#setItemParameter">setItemParameter</a>(), the value defaults to <em>id</em>. <p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#disconnectItem">disconnectItem</a>() and <a href="#setItemParameter">setItemParameter</a>(). <h3 class=fn>void <a name="menuContentsChanged"></a>QMenuData::menuContentsChanged ()<tt> [virtual protected]</tt> </h3> Virtual function; notifies subclasses that one or more items have been inserted or removed. <p>Reimplemented in <a href="qmenubar.html#menuContentsChanged">QMenuBar</a>. <h3 class=fn>void <a name="menuDelPopup"></a>QMenuData::menuDelPopup ( <a href="qpopupmenu.html">QPopupMenu</a> * )<tt> [virtual protected]</tt> </h3> Virtual function; notifies subclasses that a popup menu item has been removed. <h3 class=fn>void <a name="menuInsPopup"></a>QMenuData::menuInsPopup ( <a href="qpopupmenu.html">QPopupMenu</a> * )<tt> [virtual protected]</tt> </h3> Virtual function; notifies subclasses that a popup menu item has been inserted. <h3 class=fn>void <a name="menuStateChanged"></a>QMenuData::menuStateChanged ()<tt> [virtual protected]</tt> </h3> Virtual function; notifies subclasses that one or more items have changed state (enabled/disabled or checked/unchecked). <p>Reimplemented in <a href="qmenubar.html#menuStateChanged">QMenuBar</a>. <h3 class=fn><a href="qpixmap.html">QPixmap</a> * <a name="pixmap"></a>QMenuData::pixmap ( int id ) const </h3> Returns the pixmap that has been set for menu item <em>id</em>, or 0 if no pixmap has been set. <p> <p>See also <a href="#changeItem">changeItem</a>(), <a href="#text">text</a>() and <a href="#iconSet">iconSet</a>(). <h3 class=fn>void <a name="removeItem"></a>QMenuData::removeItem ( int id ) </h3> Removes the menu item that has the identifier <em>id</em>. <p>See also <a href="#removeItemAt">removeItemAt</a>() and <a href="#clear">clear</a>(). <h3 class=fn>void <a name="removeItemAt"></a>QMenuData::removeItemAt ( int index ) </h3> Removes the menu item at position <em>index</em>. <p>See also <a href="#removeItem">removeItem</a>() and <a href="#clear">clear</a>(). <h3 class=fn>void <a name="setAccel"></a>QMenuData::setAccel ( const <a href="qkeysequence.html">QKeySequence</a> & key, int id ) </h3> Sets the accelerator key for the menu item <em>id</em> to <em>key</em>. <p> An accelerator key consists of a key code and a combination of the modifiers <tt>SHIFT</tt>, <tt>CTRL</tt>, <tt>ALT</tt> or <tt>UNICODE_ACCEL</tt> (OR'ed or added). The header file qnamespace.h contains a list of key codes. <p> Defining an accelerator key produces a text that is added to the menu item; for instance, <tt>CTRL</tt> + <tt>Key_O</tt> produces "Ctrl+O". The text is formatted differently for different platforms. <p> Note that keyboard accelerators in Qt are not application-global, instead they are bound to a certain top-level window. For example, accelerators in <a href="qpopupmenu.html">QPopupMenu</a> items only work for menus that are associated with a certain window. This is true for popup menus that live in a menu bar since their accelerators will then be installed in the menu bar itself. This also applies to stand-alone popup menus that have a top-level widget in their parentWidget() chain. The menu will then install its accelerator object on that top-level widget. For all other cases use an independent <a href="qaccel.html">QAccel</a> object. <p> Example: <pre> <a href="qmenubar.html">QMenuBar</a> *mainMenu = new <a href="qmenubar.html">QMenuBar</a>; <a href="qpopupmenu.html">QPopupMenu</a> *fileMenu = new <a href="qpopupmenu.html">QPopupMenu</a>; // file sub menu fileMenu-><a href="#insertItem">insertItem</a>( "Open Document", 67 ); // add "Open" item fileMenu-><a href="#setAccel">setAccel</a>( CTRL + Key_O, 67 ); // Control and O to open fileMenu-><a href="#insertItem">insertItem</a>( "Quit", 69 ); // add "Quit" item fileMenu-><a href="#setAccel">setAccel</a>( CTRL + ALT + Key_Delete, 69 ); mainMenu-><a href="#insertItem">insertItem</a>( "File", fileMenu ); // add the file menu </pre> <p> If you need to translate accelerators, use tr() with a string: <pre> fileMenu->setAccel( tr("Ctrl+O"), 67 ); </pre> <p> You can also specify the accelerator in the <a href="#insertItem">insertItem</a>() function. You may prefer to use <a href="qaction.html">QAction</a> to associate accelerators with menu items. <p> <p>See also <a href="#accel">accel</a>(), <a href="#insertItem">insertItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qaction.html">QAction</a>. <p>Example: <a href="menu-example.html#x1125">menu/menu.cpp</a>. <h3 class=fn>void <a name="setId"></a>QMenuData::setId ( int index, int id )<tt> [virtual]</tt> </h3> Sets the <a href="qmenudata.html#menu-identifier">menu identifier</a> of the item at <em>index</em> to <em>id</em>. <p> If index is out of range, the operation is ignored. <p> <p>See also <a href="#idAt">idAt</a>(). <h3 class=fn>void <a name="setItemChecked"></a>QMenuData::setItemChecked ( int id, bool check ) </h3> If <em>check</em> is TRUE, checks the menu item with id <em>id</em>; otherwise unchecks the menu item with id <em>id</em>. Calls <a href="qpopupmenu.html#setCheckable">QPopupMenu::setCheckable</a>( TRUE ) if necessary. <p> <p>See also <a href="#isItemChecked">isItemChecked</a>(). <p>Examples: <a href="canvas-example.html#x2539">canvas/canvas.cpp</a>, <a href="grapher-nsplugin-example.html#x2601">grapher/grapher.cpp</a>, <a href="mdi-example.html#x1150">mdi/application.cpp</a>, <a href="menu-example.html#x1126">menu/menu.cpp</a>, <a href="progress-example.html#x841">progress/progress.cpp</a>, <a href="scrollview-example.html#x489">scrollview/scrollview.cpp</a> and <a href="showimg-example.html#x430">showimg/showimg.cpp</a>. <h3 class=fn>void <a name="setItemEnabled"></a>QMenuData::setItemEnabled ( int id, bool enable ) </h3> If <em>enable</em> is TRUE, enables the menu item with identifier <em>id</em>; otherwise disables the menu item with identifier <em>id</em>. <p>See also <a href="#isItemEnabled">isItemEnabled</a>(). <p>Examples: <a href="mdi-example.html#x1151">mdi/application.cpp</a>, <a href="menu-example.html#x1127">menu/menu.cpp</a>, <a href="progress-example.html#x842">progress/progress.cpp</a> and <a href="showimg-example.html#x431">showimg/showimg.cpp</a>. <h3 class=fn>bool <a name="setItemParameter"></a>QMenuData::setItemParameter ( int id, int param ) </h3> Sets the parameter of the activation signal of item <em>id</em> to <em>param</em>. <p> If any receiver takes an integer parameter, this value is passed. <p> <p>See also <a href="#connectItem">connectItem</a>(), <a href="#disconnectItem">disconnectItem</a>() and <a href="#itemParameter">itemParameter</a>(). <p>Example: <a href="mdi-example.html#x1152">mdi/application.cpp</a>. <h3 class=fn>void <a name="setWhatsThis"></a>QMenuData::setWhatsThis ( int id, const <a href="qstring.html">QString</a> & text ) </h3> Sets <em>text</em> as What's This help for the menu item with identifier <em>id</em>. <p> <p>See also <a href="#whatsThis">whatsThis</a>(). <p>Examples: <a href="simple-application-example.html#x1922">application/application.cpp</a> and <a href="mdi-example.html#x1153">mdi/application.cpp</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QMenuData::text ( int id ) const </h3> Returns the text that has been set for menu item <em>id</em>, or a <a href="qstring.html#operator!">null string</a> if no text has been set. <p> <p>See also <a href="#changeItem">changeItem</a>(), <a href="#pixmap">pixmap</a>() and <a href="#iconSet">iconSet</a>(). <p>Examples: <a href="qdir-example.html#x789">qdir/qdir.cpp</a> and <a href="showimg-example.html#x432">showimg/showimg.cpp</a>. <h3 class=fn>void <a name="updateItem"></a>QMenuData::updateItem ( int id )<tt> [virtual]</tt> </h3> Virtual function; notifies subclasses about an item with <em>id</em> that has been changed. <p>Reimplemented in <a href="qpopupmenu.html#updateItem">QPopupMenu</a>. <h3 class=fn><a href="qstring.html">QString</a> <a name="whatsThis"></a>QMenuData::whatsThis ( int id ) const </h3> Returns the What's This help text for the item with identifier <em>id</em> or <a href="qstring.html#QString-null">QString::null</a> if no text has yet been defined. <p> <p>See also <a href="#setWhatsThis">setWhatsThis</a>(). <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2001 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2001 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>