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

📄 qpopupmenu.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
📖 第 1 页 / 共 2 页
字号:
A QPopupMenu can also provide a tear-off menu. A tear-off menu is a "torn off" copy of a menu that lives in a separate window. This makes it possible for the user to "tear off" frequently used menus and position them in a convenient place on the screen. If you want that functionality for a certain menu, insert a tear-off handle with insertTearOffHandle(). When using tear-off menus, keep in mind that the concept isn't typically used on MS-Windows, so users may not be familiar with it. Consider using a QToolBar instead..PPmenu/menu.cpp is a typical example of QMenuBar and QPopupMenu use..PP<img src=qpopmenu-m.png> <img src=qpopmenu-w.png>.PPSee also QMenuBar and GUI Design Handbook: Menu, Drop-Down and Pop-Up.PPExamples:.(lqtimage/qtimage.cpp grapher/grapher.cpp mainlyQt/editor.cpp layout/layout.cpp menu/menu.cpp progress/progress.cpp scrollview/scrollview.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QPopupMenu::QPopupMenu ( QWidget * parent=0, const char * name=0 )"Constructs a popup menu with a parent and a widget name..PPAlthough a popup menu is always a top level widget, if a parent is passed, the popup menu will be deleted on destruction of that parent (as with any other QObject)..SH "QPopupMenu::~QPopupMenu ()"Destructs the popup menu..SH "void QPopupMenu::aboutToHide () \fC[signal]\fR"This signal is emitted just before the popup menu is hidden after it has been displayed..PPSee also aboutToShow(), setItemEnabled(), setItemChecked(), insertItem() and removeItem()..SH "void QPopupMenu::aboutToShow () \fC[signal]\fR"This signal is emitted just before the popup menu is displayed. You can connect it to any slot that sets up the menu contents (e.g. to ensure that the right items are enabled)..PPSee also aboutToHide(), setItemEnabled(), setItemChecked(), insertItem() and removeItem()..SH "void QPopupMenu::activateItemAt ( int index )"Reimplemented for internal reasons; the API is not affected..SH "void QPopupMenu::activated ( int id ) \fC[signal]\fR"This signal is emitted when a menu item is selected; \fIid\fR is the id of the selected item..PPNormally, you will connect each menu item to a single slot using QMenuData::insertItem(), but sometimes you will want to connect several items to a single slot (most often if the user selects from an array). This signal is handy in such cases..PPSee also highlighted() and QMenuData::insertItem()..SH "void QPopupMenu::closeEvent ( QCloseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "int QPopupMenu::columns () const \fC[protected]\fR"If a popup menu does not fit on the screen, it layouts itself in multiple columns until it fits..PPThis functions returns in how many..PPSee also sizeHint()..SH "bool QPopupMenu::customWhatsThis () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::drawContents ( QPainter * p ) \fC[virtual protected]\fR"Draws all menu items..PPReimplemented from QFrame..SH "void QPopupMenu::drawItem ( QPainter * p, int tab_, QMenuItem * mi, bool act, int x, int y, int w, int h ) \fC[protected]\fR"Draws item \fImi\fR in the area \fIx, y, w, h,\fR using painter \fIp.\fR The item is drawn active or inactive according to \fIact,\fR and using the rightmost \fItab_\fR pixels for accelerator text..PPSee also QStyle::drawPopupMenuItem()..SH "int QPopupMenu::exec ()"Execute this popup synchronously..PPSimilar to the above function, but the position of the popup is not set, so you must choose an appropriate position. The function move the popup if it is partially off-screen..PPMore common usage is to position the popup at the current mouse position:.PP.nf.br      exec(QCursor::pos());.fi.PPor aligned to a widget:.PP.nf.br      exec(somewidget.mapToGlobal(QPoint(0,0)));.fi.SH "int QPopupMenu::exec ( const QPoint & pos, int indexAtPoint = 0 )"Execute this popup synchronously..PPOpens 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()..PPThe return code is the ID of the selected item in either the popup menu or one of its submenus, or -1 if no item is selected (normally because the user presses Escape)..PPNote that all signals are emitted as usual. If you connect a menu item to a slot and call the menu's exec(), you get the result both via the signal-slot connection and in the return value of exec()..PPCommon usage is to position the popup at the current mouse position:.PP.nf.br      exec(QCursor::pos());.fi.PPor aligned to a widget:.PP.nf.br      exec(somewidget.mapToGlobal(QPoint(0,0)));.fi.PPWhen positioning a popup with exec() or popup(), keep in mind that you cannot rely on the popup menu's current size(). For performance reasons, the popup adapts its size only when actually needed. 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..PPSee also popup() and sizeHint()..SH "void QPopupMenu::focusInEvent ( QFocusEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "bool QPopupMenu::focusNextPrevChild ( bool next ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::focusOutEvent ( QFocusEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::hide () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::highlighted ( int id ) \fC[signal]\fR"This signal is emitted when a menu item is highlighted; \fIid\fR is the id of the highlighted item..PPNormally, you will connect each menu item to a single slot using QMenuData::insertItem(), but sometimes you will want to connect several items to a single slot (most often if the user selects from an array). This signal is handy in such cases..PPSee also activated() and QMenuData::insertItem()..SH "int QPopupMenu::idAt ( const QPoint & pos ) const"Return the id of the item at \fIpos,\fR or -1 if there is no item there, or if it is a separator item..SH "int QPopupMenu::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 QMenuData::setId() and QMenuData::indexOf()..PPExamples:.(lscrollview/scrollview.cpp.)l.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 - when selected - creates a copy of the menu. This "torn off" copy lives in a separate window. It contains the same choices as the original menu, with the exception of the tear-off handle..PPYou may also want to set a proper window title for the tear-off menu with setCaption()..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..PPExamples:.(lmenu/menu.cpp.)l.SH "bool QPopupMenu::isCheckable () const"Returns whether display of check marks by the menu items is enabled..PPSee also setCheckable() and QMenuData::setItemChecked()..SH "int QPopupMenu::itemHeight ( QMenuItem * mi ) const \fC[protected]\fR"Calculates the height in pixels of the item \fImi.\fR.SH "int QPopupMenu::itemHeight ( int row ) const \fC[protected]\fR"Calculates the height in pixels of the item in row \fIrow.\fR.SH "void QPopupMenu::keyPressEvent ( QKeyEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::mouseMoveEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::mousePressEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::mouseReleaseEvent ( QMouseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::paintEvent ( QPaintEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::popup ( const QPoint & pos, int indexAtPoint = 0 )"Opens 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(), keep in mind that you cannot rely on the popup menu's current size(). For performance reasons, the popup adapts its size only when actually needed. 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..PPExamples:.(lqtimage/qtimage.cpp.)l.SH "void QPopupMenu::setActiveItem ( int i ) \fC[virtual]\fR"Sets the currently active item to \fIi\fR and repaints as necessary..SH "void QPopupMenu::setCheckable ( bool enable ) \fC[virtual]\fR"Enables or disables display of check marks by the menu items..PPNotice that checking is always enabled when in windows-style..PPSee also isCheckable() and QMenuData::setItemChecked()..PPExamples:.(lgrapher/grapher.cpp menu/menu.cpp progress/progress.cpp scrollview/scrollview.cpp.)l.SH "void QPopupMenu::setFont ( const QFont & font ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::show () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QSize QPopupMenu::sizeHint () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::styleChange ( QStyle & old ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPopupMenu::timerEvent ( QTimerEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QObject..SH "void QPopupMenu::updateItem ( int id ) \fC[virtual]\fR"Updates the item with identity \fIid.\fR.PPReimplemented from QMenuData..SH "void QPopupMenu::activatedRedirect ( int id ) \fC[signal]\fR"For internal use only..SH "void QPopupMenu::highlightedRedirect ( int id ) \fC[signal]\fR"For internal use only..SH "SEE ALSO".BR http://doc.trolltech.com/qpopupmenu.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

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