📄 qpopupmenu.3qt
字号:
.PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel(), and connectItem()..SH "int QMenuData::insertItem ( const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a menu item with pixmap \fIpixmap\fR, submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR position..PPThe \fIpopup\fR 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..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel(), and connectItem()..SH "int QMenuData::insertItem ( const QIconSet & icon, const QPixmap & pixmap, QPopupMenu * popup, int id = -1, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a menu item with icon \fIicon\fR, pixmap \fIpixmap\fR submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR position. The icon will be displayed to the left of the pixmap in the item..PPThe \fIpopup\fR 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..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel(), and connectItem()..SH "int QMenuData::insertItem ( QWidget * widget, int id = -1, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a menu item that consists of the widget \fIwidget\fR with optional id \fIid\fR, and optional \fIindex\fR position..PPOwnership of \fIwidget\fR is transferred to the popup menu or to the menu bar..PPTheoretically, any widget can be inserted into a popup menu. In practice, this only makes sense with certain widgets..PPIf a widget is not focus-enabled (see QWidget::isFocusEnabled()), 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 QLabel if you need a popup menu with a title..PPIf 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 \fCArrowUp\fR and \fCArrowDown\fR 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 QLineEdit, 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 QWidget::focusNextPrevChild(). Futhermore, if the embedded widget closes the menu when the user made a selection, this can be done safely by calling:.PP.nf.br if ( isVisible() &&.br parentWidget() &&.br parentWidget()->inherits("QPopupMenu") ).br parentWidget()->close();.br.fi.PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem()..SH "int QMenuData::insertItem ( const QIconSet & icon, QCustomMenuItem * custom, int id = -1, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a custom menu item \fIcustom\fR with an \fIicon\fR and with optional id \fIid\fR, and optional \fIindex\fR position..PPThis only works with popup menus. It is not supported for menu bars. Ownership of \fIcustom\fR is transferred to the popup menu..PPIf you want to connect a custom item to a slot, use connectItem()..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also connectItem(), removeItem(), and QCustomMenuItem..SH "int QMenuData::insertItem ( QCustomMenuItem * custom, int id = -1, int index = -1 )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts a custom menu item \fIcustom\fR with optional id \fIid\fR, and optional \fIindex\fR position..PPThis only works with popup menus. It is not supported for menu bars. Ownership of \fIcustom\fR is transferred to the popup menu..PPIf you want to connect a custom item to a slot, use connectItem()..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also connectItem(), removeItem(), and QCustomMenuItem..SH "int QMenuData::insertSeparator ( int index = -1 )"Inserts a separator at position \fIindex\fR. The separator becomes the last menu item if \fIindex\fR is negative..PPIn 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)..PPExamples:.)l addressbook/mainwindow.cpp, mdi/application.cpp, menu/menu.cpp, progress/progress.cpp, scrollview/scrollview.cpp, showimg/showimg.cpp, and sound/sound.cpp..SH "int QPopupMenu::insertTearOffHandle ( int id = -1, int index = -1 )"Inserts a tear-off handle into the menu. A tear-off handle is a special menu item that creates a copy of the menu when the menu is selected. This "torn-off" copy lives in a separate window. It contains the same menu items as the original menu, with the exception of the tear-off handle..PPThe handle item is assigned the identifier \fIid\fR or an automatically generated identifier if \fIid\fR is < 0. The generated identifiers (negative integers) are guaranteed to be unique within the entire application..PPThe \fIindex\fR specifies the position in the menu. The tear-off handle is appended at the end of the list if \fIindex\fR is negative..PPExample: menu/menu.cpp..SH "bool QPopupMenu::isCheckable () const"Returns TRUE if the display of check marks on menu items is enabled; otherwise returns FALSE. See the "checkable" property for details..SH "bool QMenuData::isItemChecked ( int id ) const"Returns TRUE if the menu item with the id \fIid\fR has been checked; otherwise returns FALSE..PPSee also setItemChecked()..PPExamples:.)l canvas/canvas.cpp, progress/progress.cpp, and showimg/showimg.cpp..SH "bool QMenuData::isItemEnabled ( int id ) const"Returns TRUE if the item with identifier \fIid\fR is enabled; otherwise returns FALSE.PPSee also setItemEnabled() and isItemVisible()..SH "bool QMenuData::isItemVisible ( int id ) const"Returns TRUE if the menu item with the id \fIid\fR is visible; otherwise returns FALSE..PPSee also setItemVisible()..SH "int QPopupMenu::itemHeight ( int row ) const\fC [protected]\fR"Calculates the height in pixels of the item in row \fIrow\fR..SH "int QPopupMenu::itemHeight ( QMenuItem * mi ) const\fC [protected]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPCalculates the height in pixels of the menu item \fImi\fR..SH "int QMenuData::itemParameter ( int id ) const"Returns the parameter of the activation signal of item \fIid\fR..PPIf no parameter has been specified for this item with setItemParameter(), the value defaults to \fIid\fR..PPSee also connectItem(), disconnectItem(), and setItemParameter()..SH "QPixmap * QMenuData::pixmap ( int id ) const"Returns the pixmap that has been set for menu item \fIid\fR, or 0 if no pixmap has been set..PPSee also changeItem(), text(), and iconSet()..SH "void QPopupMenu::popup ( const QPoint & pos, int indexAtPoint = -1 )"Displays the popup menu so that the item number \fIindexAtPoint\fR will be at the specified \fIglobal\fR position \fIpos\fR. To translate a widget's local coordinates into global coordinates, use QWidget::mapToGlobal()..PPWhen positioning a popup with exec() or popup(), bear in mind that you cannot rely on the popup menu's current size(). For performance reasons, the popup adapts its size only when necessary, so in many cases, the size before and after the show is different. Instead, use sizeHint(). It calculates the proper size depending on the menu's current contents..PPExample: listviews/listviews.cpp..SH "void QMenuData::removeItem ( int id )"Removes the menu item that has the identifier \fIid\fR..PPSee also removeItemAt() and clear()..PPExample: chart/chartform.cpp..SH "void QMenuData::removeItemAt ( int index )"Removes the menu item at position \fIindex\fR..PPSee also removeItem() and clear()..SH "void QMenuData::setAccel ( const QKeySequence & key, int id )"Sets the accelerator key for the menu item \fIid\fR to \fIkey\fR..PPAn 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..PPDefining an accelerator key produces a text that is added to the menu item; for instance, CTRL + Key_O produces "Ctrl+O". The text is formatted differently for different platforms..PPNote 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 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 QAccel object..PPExample:.PP.nf.br QMenuBar *mainMenu = new QMenuBar;.br QPopupMenu *fileMenu = new QPopupMenu; // file sub menu.br fileMenu->insertItem( "Open Document", 67 ); // add "Open" item.br fileMenu->setAccel( CTRL + Key_O, 67 ); // Ctrl+O to open.br fileMenu->insertItem( "Quit", 69 ); // add "Quit" item.br fileMenu->setAccel( CTRL + ALT + Key_Delete, 69 ); // add Alt+Del to quit.br mainMenu->insertItem( "File", fileMenu ); // add the file menu.br.fi.PPIf you need to translate accelerators, use tr() with a string:.PP.nf.br fileMenu->setAccel( tr("Ctrl+O"), 67 );.br.fi.PPYou can also specify the accelerator in the insertItem() function. You may prefer to use QAction to associate accelerators with menu items..PPSee also accel(), insertItem(), QAccel, and QAction..PPExample: menu/menu.cpp..SH "void QPopupMenu::setActiveItem ( int i )\fC [virtual]\fR"Sets the currently active item to index \fIi\fR and repaints as necessary..SH "void QPopupMenu::setCheckable ( bool )\fC [virtual]\fR"Sets whether the display of check marks on menu items is enabled. See the "checkable" property for details..SH "void QMenuData::setItemChecked ( int id, bool check )"If \fIcheck\fR is TRUE, checks the menu item with id \fIid\fR; otherwise unchecks the menu item with id \fIid\fR. Calls QPopupMenu::setCheckable( TRUE ) if necessary..PPSee also isItemChecked()..PPExamples:.)l canvas/canvas.cpp, mdi/application.cpp, menu/menu.cpp, progress/progress.cpp, scrollview/scrollview.cpp, and showimg/showimg.cpp..SH "void QMenuData::setItemEnabled ( int id, bool enable )"If \fIenable\fR is TRUE, enables the menu item with identifier \fIid\fR; otherwise disables the menu item with identifier \fIid\fR..PPSee also isItemEnabled()..PPExamples:.)l mdi/application.cpp, menu/menu.cpp, progress/progress.cpp, and showimg/showimg.cpp..SH "bool QMenuData::setItemParameter ( int id, int param )"Sets the parameter of the activation signal of item \fIid\fR to \fIparam\fR..PPIf any receiver takes an integer parameter, this value is passed..PPSee also connectItem(), disconnectItem(), and itemParameter()..PPExample: mdi/application.cpp..SH "void QMenuData::setItemVisible ( int id, bool visible )"If \fIvisible\fR is TRUE, shows the menu item with id \fIid\fR; otherwise hides the menu item with id \fIid\fR..PPSee also isItemVisible() and isItemEnabled()..SH "void QMenuData::setWhatsThis ( int id, const QString & text )"Sets \fItext\fR as What's This help for the menu item with identifier \fIid\fR..PPSee also whatsThis()..PPExamples:.)l application/application.cpp and mdi/application.cpp..SH "QString QMenuData::text ( int id ) const"Returns the text that has been set for menu item \fIid\fR, or QString::null if no text has been set..PPSee also changeItem(), pixmap(), and iconSet()..PPExamples:.)l qdir/qdir.cpp and showimg/showimg.cpp..SH "void QPopupMenu::updateItem ( int id )\fC [virtual]\fR"Updates the item with identity \fIid\fR..PPReimplemented from QMenuData..SH "QString QMenuData::whatsThis ( int id ) const"Returns the What's This help text for the item with identifier \fIid\fR or QString::null if no text has yet been defined..PPSee also setWhatsThis()..SS "Property Documentation".SH "bool checkable"This property holds whether the display of check marks on menu items is enabled..PPWhen TRUE, the display of check marks on menu items is enabled. Checking is always enabled when in Windows-style..PPSee also QMenuData::setItemChecked()..PPSet this property's value with setCheckable() and get this property's value with isCheckable()..SH "SEE ALSO".BR http://doc.trolltech.com/qpopupmenu.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qpopupmenu.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -