qpopupmenu.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 781 行 · 第 1/4 页
HTML
781 行
<p>Examples: <a href="addressbook-example.html#x519">addressbook/mainwindow.cpp</a>, <a href="mdi-example.html#x2014">mdi/application.cpp</a>, <a href="menu-example.html#x1861">menu/menu.cpp</a>, <a href="progress-example.html#x37">progress/progress.cpp</a>, <a href="scrollview-example.html#x722">scrollview/scrollview.cpp</a>, <a href="showimg-example.html#x1266">showimg/showimg.cpp</a> and <a href="sound-example.html#x2658">sound/sound.cpp</a>.<h3 class=fn>int <a name="insertTearOffHandle"></a>QPopupMenu::insertTearOffHandle ( int id = -1, int index = -1 )</h3>Inserts a tear-off handle into the menu. A tear-off handle is aspecial menu item that creates a copy of the menu when the menu isselected. This "torn-off" copy lives in a separate window. Itcontains the same menu items as the original menu, with the exceptionof the tear-off handle.<p> The handle item is assigned the identifier <em>id</em> or an automaticallygenerated identifier if <em>id</em> is < 0. The generated identifiers(negative integers) are guaranteed to be unique within the entireapplication.<p> The <em>index</em> specifies the position in the menu. The tear-offhandle is appended at the end of the list if <em>index</em> is negative.<p>Example: <a href="menu-example.html#x1869">menu/menu.cpp</a>.<h3 class=fn>bool <a name="isCheckable"></a>QPopupMenu::isCheckable () const</h3><p>Returns TRUE if the display of check marks on menu items is enabled; otherwise returns FALSE.See the <a href="qpopupmenu.html#checkable-prop">"checkable"</a> property for details.<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="qmenudata.html#setItemChecked">setItemChecked</a>().<p>Examples: <a href="canvas-example.html#x2714">canvas/canvas.cpp</a>, <a href="progress-example.html#x38">progress/progress.cpp</a> and <a href="showimg-example.html#x1267">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; otherwisereturns FALSE<p>See also <a href="qmenudata.html#setItemEnabled">setItemEnabled</a>().<h3 class=fn>int <a name="itemHeight"></a>QPopupMenu::itemHeight ( int row ) const<tt> [protected]</tt></h3>Calculates the height in pixels of the item in row <em>row</em>.<h3 class=fn>int <a name="itemHeight-2"></a>QPopupMenu::itemHeight ( QMenuItem * mi ) const<tt> [protected]</tt></h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Calculates the height in pixels of the menu item <em>mi</em>.<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="qmenudata.html#setItemParameter">setItemParameter</a>(), the value defaults to <em>id</em>.<p> <p>See also <a href="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#disconnectItem">disconnectItem</a>() and <a href="qmenudata.html#setItemParameter">setItemParameter</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 pixmaphas been set.<p> <p>See also <a href="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#text">text</a>() and <a href="qmenudata.html#iconSet">iconSet</a>().<h3 class=fn>void <a name="popup"></a>QPopupMenu::popup ( const <a href="qpoint.html">QPoint</a> & pos, int indexAtPoint = -1 )</h3>Displays the popup menu so that the item number <em>indexAtPoint</em> will beat the specified <em>global</em> position <em>pos</em>. To translate a widget'slocal coordinates into global coordinates, use <a href="qwidget.html#mapToGlobal">QWidget::mapToGlobal</a>().<p> When positioning a popup with <a href="#exec">exec</a>() or <a href="#popup">popup</a>(), bear in mind thatyou cannot rely on the popup menu's current <a href="qwidget.html#size">size</a>(). For performancereasons, the popup adapts its size only when necessary, so in manycases, the size before and after the show is different. Instead, use<a href="qwidget.html#sizeHint">sizeHint</a>(). It calculates the proper size depending on the menu'scurrent contents.<p> <p>Examples: <a href="listviews-example.html#x346">listviews/listviews.cpp</a> and <a href="qtimage-nsplugin-example.html#x2584">qtimage/qtimage.cpp</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="qmenudata.html#removeItemAt">removeItemAt</a>() and <a href="qmenudata.html#clear">clear</a>().<p>Example: <a href="canvas-chart-example.html#x2602">chart/chartform.cpp</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="qmenudata.html#removeItem">removeItem</a>() and <a href="qmenudata.html#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<a href="qt.html#Modifier-enum">SHIFT</a>, <a href="qt.html#Modifier-enum">CTRL</a>, <a href="qt.html#Modifier-enum">ALT</a> or <a href="qt.html#Modifier-enum">UNICODE_ACCEL</a> (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 themenu item; for instance, <a href="qt.html#Modifier-enum">CTRL</a> + <a href="qt.html#Key-enum">Key_O</a> produces "Ctrl+O". Thetext 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 QPopupMenu items only work for menus that areassociated with a certain window. This is true for popup menus thatlive in a menu bar since their accelerators will then be installedin the menu bar itself. This also applies to stand-alone popup menusthat have a top-level widget in their <a href="qwidget.html#parentWidget">parentWidget</a>() chain. The menuwill 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>; QPopupMenu *fileMenu = new QPopupMenu; // file sub menu fileMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "Open Document", 67 ); // add "Open" item fileMenu-><a href="qmenudata.html#setAccel">setAccel</a>( CTRL + Key_O, 67 ); // Control and O to open fileMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "Quit", 69 ); // add "Quit" item fileMenu-><a href="qmenudata.html#setAccel">setAccel</a>( CTRL + ALT + Key_Delete, 69 ); mainMenu-><a href="qmenudata.html#insertItem">insertItem</a>( "File", fileMenu ); // add the file menu </pre> <p> If you need to translate accelerators, use <a href="qobject.html#tr">tr</a>() with a string:<pre> fileMenu->setAccel( <a href="qobject.html#tr">tr</a>("Ctrl+O"), 67 ); </pre> <p> You can also specify the accelerator in the <a href="qmenudata.html#insertItem">insertItem</a>() function.You may prefer to use <a href="qaction.html">QAction</a> to associate accelerators with menuitems.<p> <p>See also <a href="qmenudata.html#accel">accel</a>(), <a href="qmenudata.html#insertItem">insertItem</a>(), <a href="qaccel.html">QAccel</a> and <a href="qaction.html">QAction</a>.<p>Example: <a href="menu-example.html#x1862">menu/menu.cpp</a>.<h3 class=fn>void <a name="setActiveItem"></a>QPopupMenu::setActiveItem ( int i )<tt> [virtual]</tt></h3> Sets the currently active item to <em>i</em> and repaints as necessary.<h3 class=fn>void <a name="setCheckable"></a>QPopupMenu::setCheckable ( bool )<tt> [virtual]</tt></h3><p>Sets whether the display of check marks on menu items is enabled.See the <a href="qpopupmenu.html#checkable-prop">"checkable"</a> property for details.<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>; otherwiseunchecks the menu item with id <em>id</em>.Calls <a href="#setCheckable">QPopupMenu::setCheckable</a>( TRUE ) if necessary.<p> <p>See also <a href="qmenudata.html#isItemChecked">isItemChecked</a>().<p>Examples: <a href="canvas-example.html#x2715">canvas/canvas.cpp</a>, <a href="grapher-nsplugin-example.html#x2757">grapher/grapher.cpp</a>, <a href="mdi-example.html#x2015">mdi/application.cpp</a>, <a href="menu-example.html#x1863">menu/menu.cpp</a>, <a href="progress-example.html#x39">progress/progress.cpp</a>, <a href="scrollview-example.html#x723">scrollview/scrollview.cpp</a> and <a href="showimg-example.html#x1268">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="qmenudata.html#isItemEnabled">isItemEnabled</a>().<p>Examples: <a href="mdi-example.html#x2016">mdi/application.cpp</a>, <a href="menu-example.html#x1864">menu/menu.cpp</a>, <a href="progress-example.html#x40">progress/progress.cpp</a> and <a href="showimg-example.html#x1269">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="qmenudata.html#connectItem">connectItem</a>(), <a href="qmenudata.html#disconnectItem">disconnectItem</a>() and <a href="qmenudata.html#itemParameter">itemParameter</a>().<p>Example: <a href="mdi-example.html#x2017">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="qmenudata.html#whatsThis">whatsThis</a>().<p>Examples: <a href="simple-application-example.html#x1518">application/application.cpp</a> and <a href="mdi-example.html#x2018">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="qmenudata.html#changeItem">changeItem</a>(), <a href="qmenudata.html#pixmap">pixmap</a>() and <a href="qmenudata.html#iconSet">iconSet</a>().<p>Examples: <a href="qdir-example.html#x1824">qdir/qdir.cpp</a> and <a href="showimg-example.html#x1270">showimg/showimg.cpp</a>.<h3 class=fn>void <a name="updateItem"></a>QPopupMenu::updateItem ( int id )<tt> [virtual]</tt></h3>Updates the item with identity <em>id</em>.<p>Reimplemented from <a href="qmenudata.html#updateItem">QMenuData</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="qmenudata.html#setWhatsThis">setWhatsThis</a>().<hr><h2>Property Documentation</h2><h3 class=fn>bool <a name="checkable-prop"></a>checkable</h3><p>This property holds whether the display of check marks on menu items is enabled.<p>When TRUE, the display of check marks on menu items is enabled.Checking is always enabled when in Windows-style.<p> <p>See also <a href="qmenudata.html#setItemChecked">QMenuData::setItemChecked</a>().<p>Set this property's value with <a href="#setCheckable">setCheckable</a>() and get this property's value with <a href="#isCheckable">isCheckable</a>().<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright © 1995-2002<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 © 2002 <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.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?