📄 qmenudata.3qt
字号:
'\" t.TH QMenuData 3qt "5 August 2004" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQMenuData \- Base class for.br.PP\fC#include <qmenudata.h>\fR.PPInherited by QMenuBar and QPopupMenu..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQMenuData\fR () ".br.ti -1c.BI "virtual \fB~QMenuData\fR () ".br.ti -1c.BI "uint \fBcount\fR () const".br.ti -1c.BI "int \fBinsertItem\fR ( const QString & " "text" ", const QObject * " "receiver" ", const char * " "member" ", int " "accel" " = 0, int " "id" " = -1, int " "index" " = -1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", const QString & " "text" ", const QObject * " "receiver" ", const char * " "member" ", int " "accel" " = 0, int " "id" " = -1, int " "index" " = -1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QPixmap & " "pixmap" ", const QObject * " "receiver" ", const char * " "member" ", int " "accel" " = 0, int " "id" " = -1, int " "index" " = -1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", const QPixmap & " "pixmap" ", const QObject * " "receiver" ", const char * " "member" ", int " "accel" " = 0, int " "id" " = -1, int " "index" " = -1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QString & " "text" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", const QString & " "text" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QString & " "text" ", QPopupMenu * " "popup" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", const QString & " "text" ", QPopupMenu * " "popup" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QPixmap & " "pixmap" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", const QPixmap & " "pixmap" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QPixmap & " "pixmap" ", QPopupMenu * " "popup" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", const QPixmap & " "pixmap" ", QPopupMenu * " "popup" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( QWidget * " "widget" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( const QIconSet & " "icon" ", QCustomMenuItem * " "custom" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertItem\fR ( QCustomMenuItem * " "custom" ", int " "id" "=-1, int " "index" "=-1 ) ".br.ti -1c.BI "int \fBinsertSeparator\fR ( int " "index" "=-1 ) ".br.ti -1c.BI "void \fBremoveItem\fR ( int id ) ".br.ti -1c.BI "void \fBremoveItemAt\fR ( int index ) ".br.ti -1c.BI "void \fBclear\fR () ".br.ti -1c.BI "int \fBaccel\fR ( int id ) const".br.ti -1c.BI "void \fBsetAccel\fR ( int " "key" ", int id ) ".br.ti -1c.BI "QIconSet* \fBiconSet\fR ( int id ) const".br.ti -1c.BI "QString \fBtext\fR ( int id ) const".br.ti -1c.BI "QPixmap* \fBpixmap\fR ( int id ) const".br.ti -1c.BI "void \fBsetWhatsThis\fR ( int " "id" ", const QString & ) ".br.ti -1c.BI "QString \fBwhatsThis\fR ( int id ) const".br.ti -1c.BI "void \fBchangeItem\fR ( int " "id" ", const QString & text ) ".br.ti -1c.BI "void \fBchangeItem\fR ( int " "id" ", const QPixmap & pixmap ) ".br.ti -1c.BI "void \fBchangeItem\fR ( int " "id" ", const QIconSet & " "icon" ", const QString & text ) ".br.ti -1c.BI "void \fBchangeItem\fR ( int " "id" ", const QIconSet & " "icon" ", const QPixmap & pixmap ) ".br.ti -1c.BI "void changeItem ( const QString & " "text" ", int id ) \fI(obsolete)\fR".br.ti -1c.BI "void changeItem ( const QPixmap & " "pixmap" ", int id ) \fI(obsolete)\fR".br.ti -1c.BI "void changeItem ( const QIconSet & " "icon" ", const QString & " "text" ", int id ) \fI(obsolete)\fR".br.ti -1c.BI "bool \fBisItemEnabled\fR ( int id ) const".br.ti -1c.BI "void \fBsetItemEnabled\fR ( int " "id" ", bool enable ) ".br.ti -1c.BI "bool \fBisItemChecked\fR ( int id ) const".br.ti -1c.BI "void \fBsetItemChecked\fR ( int " "id" ", bool check ) ".br.ti -1c.BI "virtual void \fBupdateItem\fR ( int id ) ".br.ti -1c.BI "int \fBindexOf\fR ( int id ) const".br.ti -1c.BI "int \fBidAt\fR ( int index ) const".br.ti -1c.BI "virtual void \fBsetId\fR ( int " "index" ", int id ) ".br.ti -1c.BI "bool \fBconnectItem\fR ( int " "id" ", const QObject * " "receiver" ", const char * member ) ".br.ti -1c.BI "bool \fBdisconnectItem\fR ( int " "id" ", const QObject * " "receiver" ", const char * member ) ".br.ti -1c.BI "bool \fBsetItemParameter\fR ( int " "id" ", int param ) ".br.ti -1c.BI "int \fBitemParameter\fR ( int id ) const".br.ti -1c.BI "QMenuItem* \fBfindItem\fR ( int id ) const".br.ti -1c.BI "QMenuItem* \fBfindItem\fR ( int " "id" ", QMenuData ** parent ) const".br.ti -1c.BI "void \fBactivateItemAt\fR ( int index ) ".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBmenuContentsChanged\fR () ".br.ti -1c.BI "virtual void \fBmenuStateChanged\fR () ".br.ti -1c.BI "virtual void \fBmenuInsPopup\fR ( QPopupMenu * ) ".br.ti -1c.BI "virtual void \fBmenuDelPopup\fR ( QPopupMenu * ) ".br.ti -1c.BI "QMenuItem* \fBfindPopup\fR ( QPopupMenu *, int * " "index" " = 0 ) ".br.in -1c.SH DESCRIPTIONThe QMenuData class is a base class for QMenuBar and QPopupMenu..PPQMenuData 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)..PPThe menu item sends out an activated() signal when it is selected, and a highlighted() signal when it receives the user input focus..PPMenu items can be accessed through identifiers..PPSee also QAccel..SH MEMBER FUNCTION DOCUMENTATION.SH "QMenuData::QMenuData ()"Constructs an empty list..SH "QMenuData::~QMenuData () \fC[virtual]\fR"Removes all menu items and disconnects any signals that have been connected..SH "int QMenuData::accel ( int id ) const"Returns the accelerator key that has been defined for the menu item \fIid,\fR or 0 if it has no accelerator key..PPSee also setAccel(), QAccel and qnamespace.h..SH "void QMenuData::activateItemAt ( int index )"Activates the menu item at index \fIindex.\fR.PPIf the index is invalid (for example -1), the object itself is deactivated..SH "void QMenuData::changeItem ( const QIconSet & icon, const QString & text, int id )"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPChanges the icon and text of the menu item \fIid.\fR.PPSee also pixmap()..SH "void QMenuData::changeItem ( const QPixmap & pixmap, int id )"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPChanges the pixmap of the menu item \fIid.\fR If the item has an icon, the icon remains unchanged..PPSee also pixmap()..SH "void QMenuData::changeItem ( const QString & text, int id )"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPChanges the text of the menu item \fIid.\fR If the item has an icon, the icon remains unchanged..PPSee also text()..SH "void QMenuData::changeItem ( int id, const QIconSet & icon, const QPixmap & pixmap )"Changes the icon and pixmap of the menu item \fIid.\fR.PPSee also pixmap()..SH "void QMenuData::changeItem ( int id, const QIconSet & icon, const QString & text )"Changes the icon and text of the menu item \fIid.\fR.PPSee also pixmap()..SH "void QMenuData::changeItem ( int id, const QPixmap & pixmap )"Changes the pixmap of the menu item \fIid.\fR If the item has an icon, the icon remains unchanged..PPSee also pixmap()..SH "void QMenuData::changeItem ( int id, const QString & text )"Changes the text of the menu item \fIid.\fR If the item has an icon, the icon remains unchanged..PPSee also text()..SH "void QMenuData::clear ()"Removes all menu items..PPSee also removeItem() and removeItemAt()..SH "bool QMenuData::connectItem ( int id, const QObject * receiver, const char * member )"Connects a menu item to a receiver and a slot or signal..PPThe receiver's slot/signal is activated when the menu item is activated..PPSee also disconnectItem() and setItemParameter()..PPExamples:.(lmenu/menu.cpp.)l.SH "uint QMenuData::count () const"Returns the number of items in the menu..SH "bool QMenuData::disconnectItem ( int id, const QObject * receiver, const char * member )"Disconnects a receiver/member from a menu item..PPAll connections are removed when the menu data object is destroyed..PPSee also connectItem() and setItemParameter()..SH "QMenuItem * QMenuData::findItem ( int id ) const"Returns a pointer to the menu item with identifier \fIid,\fR or 0 if there is no item with such an identifier..PPSee also indexOf()..SH "QMenuItem * QMenuData::findItem ( int id, QMenuData ** parent ) const"Returns a pointer to the menu item with identifier \fIid,\fR or 0 if there is no item with such an identifier, and changes \fIparent\fR to point to the parent of the return value..PPSee also indexOf()..SH "QMenuItem * QMenuData::findPopup ( QPopupMenu * popup, int * index = 0 ) \fC[protected]\fR"Internal function that finds the menu item where \fIpopup\fR is located, storing its index at \fIindex\fR if \fIindex\fR is not NULL..SH "QIconSet* QMenuData::iconSet ( int id ) const"Returns the icon set that has been set for menu item \fIid,\fR or 0 if no icon set has been set..PPSee also changeItem(), text() and pixmap()..SH "int QMenuData::idAt ( int index ) const"Returns the identifier of the menu item at position \fIindex\fR in the internal list, or -1 if \fIindex\fR is out of range..PPSee also setId() and indexOf()..SH "int QMenuData::indexOf ( int id ) const"Returns the index of the menu item with identifier \fIid,\fR or -1 if there is no item with such an identifier..PPSee also idAt() and findItem()..PPExamples:.(lscrollview/scrollview.cpp.)l.SH "int QMenuData::insertItem ( const QString & text, const QObject * receiver, const char * member, int accel = 0, int id = -1, int index = -1 )"The family of insertItem() functions inserts menu items into a popup menu or a menu bar..PPA menu item is usually either a text string or a a pixmap, both with an optional icon or keyboard accelerator. As special cases it is also possible to insert custom items (see QCustomMenuItem) or even widgets into popup menus..PPSome insertItem() members take a popup menu as additional argument. Use these to insert submenus to existing menus or pulldown menus to a menu bar..PPThe amount of insert functions may look confusing, but is actually quite handy to use..PPThis default version inserts a menu item with a text, an accelerator key, an id and an optional index and connects it to an object/slot..PPExample:.PP.nf.br QMenuBar *mainMenu = new QMenuBar;.br QPopupMenu *fileMenu = new QPopupMenu;.br fileMenu->insertItem( "New", myView, SLOT(newFile()), CTRL+Key_N );.br fileMenu->insertItem( "Open", myView, SLOT(open()), CTRL+Key_O );.br mainMenu->insertItem( "File", fileMenu );.fi.PPNot all insert functions take an object/slot parameter or an accelerator key. Use connectItem() and setAccel() on these items..PPIf you will need to translate accelerators, use QAccel::stringToKey() to calculate the accelerator key:.PP.nf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -