⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmenubar.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 2 页
字号:
.br    fileMenu->insertItem( "Open", myView, SLOT(open()),    CTRL+Key_O );.br    mainMenu->insertItem( "File", fileMenu );.br.fi.PPNot all insert functions take an object/slot parameter or an accelerator key. Use connectItem() and setAccel() on these items..PPIf you need to translate accelerators, use tr() with a string description that use pass to the QKeySequence constructor:.PP.nf.br    fileMenu->insertItem( tr("Open"), myView, SLOT(open()),.br                         tr("Ctrl+O") );.br.fi.PPIn the example above, pressing Ctrl+N or selecting "Open" from the menu activates the myView->open() function..PPSome insert functions take a QIconSet parameter to specify the little menu item icon. Note that you can always pass a QPixmap object instead..PPThe \fIindex\fR specifies the position in the menu. The menu item is appended at the end of the list if \fIindex\fR is negative..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..PP\fBWarning:\fR Be careful when passing a literal 0 to insertItem() because some C++ compilers choose the wrong overloaded function. Cast the 0 to what you mean, e.g. \fC(QObject*)0\fR..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qnamespace.h..PPExamples:.)l addressbook/mainwindow.cpp, mdi/application.cpp, menu/menu.cpp, qwerty/qwerty.cpp, scrollview/scrollview.cpp and showimg/showimg.cpp..SH "int QMenuData::insertItem ( const QIconSet & icon, const QString & text, const QObject * receiver, const char * member, const QKeySequence & accel = 0, 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, text \fItext\fR, accelerator \fIaccel\fR, optional id \fIid\fR, and optional \fIindex\fR. The menu item is connected it to the \fIreceiver\fR's \fImember\fR slot. The icon will be displayed to the left of the text in the item..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qnamespace.h..SH "int QMenuData::insertItem ( const QPixmap & pixmap, const QObject * receiver, const char * member, const QKeySequence & accel = 0, 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, accelerator \fIaccel\fR, optional id \fIid\fR, and optional \fIindex\fR. The menu item is connected it to the \fIreceiver\fR's \fImember\fR slot. The icon will be displayed to the left of the text in the item..PPTo look best when being highlighted as a menu item, the pixmap should provide a mask (see QPixmap::mask())..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, const QObject * receiver, const char * member, const QKeySequence & accel = 0, 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, accelerator \fIaccel\fR, optional id \fIid\fR, and optional \fIindex\fR. The icon will be displayed to the left of the pixmap in the item. The item is connected to the \fImember\fR slot in the \fIreceiver\fR object..PPTo look best when being highlighted as a menu item, the pixmap should provide a mask (see QPixmap::mask())..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel(), connectItem(), QAccel and qnamespace.h..SH "int QMenuData::insertItem ( const QString & text, 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 text \fItext\fR, optional id \fIid\fR, and optional \fIindex\fR..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 QString & text, 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, text \fItext\fR, optional id \fIid\fR, and optional \fIindex\fR. The icon will be displayed to the left of the text in the item..PPReturns the allocated menu identifier number (\fIid\fR if \fIid\fR >= 0)..PPSee also removeItem(), changeItem(), setAccel() and connectItem()..SH "int QMenuData::insertItem ( const QString & text, 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 text \fItext\fR, submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR..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 QString & text, 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, text \fItext\fR, submenu \fIpopup\fR, optional id \fIid\fR, and optional \fIindex\fR. The icon will be displayed to the left of the text 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 ( const QPixmap & pixmap, 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, optional id \fIid\fR, and optional \fIindex\fR..PPTo look best when being highlighted as a menu item, the pixmap should provide a mask (see QPixmap::mask())..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, 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, optional id \fIid\fR, and optional \fIindex\fR. The icon will be displayed to the left of the pixmap in the item..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..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. 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..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 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 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..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 certain 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..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 certain 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, qwerty/qwerty.cpp, scrollview/scrollview.cpp and showimg/showimg.cpp..SH "bool QMenuBar::isDefaultUp () const"Returns the popup orientation. See the "defaultUp" property for details..SH "bool QMenuData::isItemEnabled ( int id ) const"Returns TRUE if the item with identifier \fIid\fR is enabled; otherwise returns FALSE.PPSee also setItemEnabled()..SH "void QMenuBar::menuContentsChanged ()\fC [virtual protected]\fR"Recomputes the menu bar's display data according to the new contents..PPYou should never need to call this; it is called automatically by QMenuData whenever it needs to be called..PPReimplemented from QMenuData..SH "void QMenuBar::menuStateChanged ()\fC [virtual protected]\fR"Recomputes the menu bar's display data according to the new state..PPYou should never need to call this; it is called automatically by QMenuData whenever it needs to be called..PPReimplemented from QMenuData..SH "void QMenuData::removeItem ( int id )"Removes the menu item that has the identifier \fIid\fR..PPSee also removeItemAt() and clear()..SH "Separator QMenuBar::separator () const"Returns in which cases a menubar sparator is drawn. See the "separator" property for details..SH "void QMenuBar::setDefaultUp ( bool )"Sets the popup orientation. See the "defaultUp" property for details..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 "void QMenuBar::setSeparator ( Separator when )\fC [virtual]\fR"Sets in which cases a menubar sparator is drawn to \fIwhen\fR. See the "separator" property for details..SH "void QMenuBar::show ()\fC [virtual]\fR"Reimplements QWidget::show() in order to set up the correct keyboard accelerators and to raise itself to the top of the widget stack..PPExample: grapher/grapher.cpp..PPReimplemented from QWidget..SS "Property Documentation".SH "bool defaultUp"This property holds the popup orientation..PPThe default popup orientation. By default, menus pop "down" the screen. By setting the property to TRUE, the menu will pop "up". You might call this for menus that are \fIbelow\fR the document to which they refer..PPIf the menu would not fit on the screen, the other direction is used rather than the default..PPSet this property's value with setDefaultUp() and get this property's value with isDefaultUp()..SH "Separator separator"This property holds in which cases a menubar sparator is drawn..PP\fBThis property is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPSet this property's value with setSeparator() and get this property's value with separator()..SH "SEE ALSO".BR http://doc.trolltech.com/qmenubar.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 (qmenubar.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -