📄 qwidget.3qt
字号:
.SH "void QWidget::enabledChange ( bool oldEnabled )\fC [virtual protected]\fR"This virtual function is called from setEnabled(). \fIoldEnabled\fR is the previous setting; you can get the new setting from isEnabled()..PPReimplement this function if your widget needs to know when it becomes enabled or disabled. You will almost certainly need to update the widget using update()..PPThe default implementation repaints the visible part of the widget..PPSee also enabled, enabled, repaint(), update(), and visibleRect..SH "void QWidget::enterEvent ( QEvent * )\fC [virtual protected]\fR"This event handler can be reimplemented in a subclass to receive widget enter events..PPAn event is sent to the widget when the mouse cursor enters the widget..PPSee also leaveEvent(), mouseMoveEvent(), and event()..SH "void QWidget::erase ( int x, int y, int w, int h )"Erases the specified area \fI(x, y, w, h)\fR in the widget without generating a paint event..PPIf \fIw\fR is negative, it is replaced with \fCwidth() - x\fR. If \fIh\fR is negative, it is replaced width \fCheight() - y\fR..PPChild widgets are not affected..PPSee also repaint()..SH "void QWidget::erase ()"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPThis version erases the entire widget..SH "void QWidget::erase ( const QRect & r )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPErases the specified area \fIr\fR in the widget without generating a paint event..SH "void QWidget::erase ( const QRegion & reg )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPErases the area defined by \fIreg\fR, without generating a paint event..PPChild widgets are not affected..SH "const QColor & QWidget::eraseColor () const"Returns the erase color of the widget..PPSee also setEraseColor(), setErasePixmap(), and backgroundColor()..SH "const QPixmap * QWidget::erasePixmap () const"Returns the widget's erase pixmap..PPSee also setErasePixmap() and eraseColor()..SH "bool QWidget::event ( QEvent * e )\fC [virtual protected]\fR"This is the main event handler; it handles event \fIe\fR. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead..PPThe main event handler first passes an event through all event filters that have been installed. If none of the filters intercept the event, it calls one of the specialized event handlers..PPKey press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent()..PPThis function returns TRUE if it is able to pass the event over to someone (i.e. someone wanted the event); otherwise returns FALSE..PPSee also closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event(), and QObject::timerEvent()..PPReimplemented from QObject..SH "QWidget * QWidget::find ( WId id )\fC [static]\fR"Returns a pointer to the widget with window identifer/handle \fIid\fR..PPThe window identifier type depends on the underlying window system, see qwindowdefs.h for the actual definition. If there is no widget with this identifier, 0 is returned..SH "QFocusData * QWidget::focusData ()\fC [protected]\fR"Returns the focus data for this widget's top-level widget..PPFocus data always belongs to the top-level widget. The focus data list contains all the widgets in this top-level widget that can accept focus, in tab order. An iterator points to the current focus widget (focusWidget() returns a pointer to this widget)..PPThis information is useful for implementing advanced versions of focusNextPrevChild()..SH "void QWidget::focusInEvent ( QFocusEvent * )\fC [virtual protected]\fR"This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget..PPA widget normally must setFocusPolicy() to something other than NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.).PPThe default implementation updates the widget if it accepts focus (see focusPolicy()). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention..PPSee also focusOutEvent(), focusPolicy, keyPressEvent(), keyReleaseEvent(), event(), and QFocusEvent..SH "bool QWidget::focusNextPrevChild ( bool next )\fC [virtual protected]\fR"Finds a new widget to give the keyboard focus to, as appropriate for Tab and Shift+Tab, and returns TRUE if is can find a new widget and FALSE if it can't,.PPIf \fInext\fR is TRUE, this function searches "forwards", if \fInext\fR is FALSE, it searches "backwards"..PPSometimes, you will want to reimplement this function. For example, a web browser might reimplement it to move its "current active link" forwards or backwards, and call QWidget::focusNextPrevChild() only when it reaches the last or first link on the "page"..PPChild widgets call focusNextPrevChild() on their parent widgets, but only the top-level widget decides where to redirect focus. By overriding this method for an object, you thus gain control of focus traversal for all child widgets..PPSee also focusData()..SH "void QWidget::focusOutEvent ( QFocusEvent * )\fC [virtual protected]\fR"This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget..PPA widget normally must setFocusPolicy() to something other than NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.).PPThe default implementation calls repaint() since the widget's colorGroup() changes from active to normal, so the widget probably needs repainting. It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention..PPSee also focusInEvent(), focusPolicy, keyPressEvent(), keyReleaseEvent(), event(), and QFocusEvent..PPExample: qmag/qmag.cpp..SH "FocusPolicy QWidget::focusPolicy () const"Returns the way the widget accepts keyboard focus. See the "focusPolicy" property for details..SH "QWidget * QWidget::focusProxy () const"Returns the focus proxy, or 0 if there is no focus proxy..PPSee also setFocusProxy()..SH "QWidget * QWidget::focusWidget () const"Returns the focus widget in this widget's window. This is not the same as QApplication::focusWidget(), which returns the focus widget in the currently active window..SH "QFont QWidget::font () const"Returns the font currently set for the widget. See the "font" property for details..SH "void QWidget::fontChange ( const QFont & oldFont )\fC [virtual protected]\fR"This virtual function is called from setFont(). \fIoldFont\fR is the previous font; you can get the new font from font()..PPReimplement this function if your widget needs to know when its font changes. You will almost certainly need to update the widget using update()..PPThe default implementation updates the widget including its geometry..PPSee also font, font, update(), and updateGeometry()..SH "QFontInfo QWidget::fontInfo () const"Returns the font info for the widget's current font. Equivalent to QFontInto(widget->font())..PPSee also font, fontMetrics(), and font..SH "QFontMetrics QWidget::fontMetrics () const"Returns the font metrics for the widget's current font. Equivalent to QFontMetrics(widget->font())..PPSee also font, fontInfo(), and font..PPExamples:.)l drawdemo/drawdemo.cpp and qmag/qmag.cpp..SH "const QColor & QWidget::foregroundColor () const"Same as paletteForegroundColor().SH "QRect QWidget::frameGeometry () const"Returns geometry of the widget relative to its parent including any window frame. See the "frameGeometry" property for details..SH "QSize QWidget::frameSize () const"Returns the size of the widget including any window frame. See the "frameSize" property for details..SH "const QRect & QWidget::geometry () const"Returns the geometry of the widget relative to its parent and excluding the window frame. See the "geometry" property for details..SH "WFlags QWidget::getWFlags () const\fC [protected]\fR"Returns the widget flags for this this widget..PPWidget flags are a combination of Qt::WidgetFlags..PPSee also testWFlags(), setWFlags(), and clearWFlags()..SH "void QWidget::grabKeyboard ()"Grabs the keyboard input..PPThis widget reveives all keyboard events until releaseKeyboard() is called; other widgets get no keyboard events at all. Mouse events are not affected. Use grabMouse() if you want to grab that..PPThe focus widget is not affected, except that it doesn't receive any keyboard events. setFocus() moves the focus as usual, but the new focus widget receives keyboard events only after releaseKeyboard() is called..PPIf a different widget is currently grabbing keyboard input, that widget's grab is released first..PPSee also releaseKeyboard(), grabMouse(), releaseMouse(), and focusWidget()..SH "void QWidget::grabMouse ()"Grabs the mouse input..PPThis widget receives all mouse events until releaseMouse() is called; other widgets get no mouse events at all. Keyboard events are not affected. Use grabKeyboard() if you want to grab that..PP\fBWarning:\fR Bugs in mouse-grabbing applications very often lock the terminal. Use this function with extreme caution, and consider using the \fC-nograb\fR command line option while debugging..PPIt is almost never necessary to grab the mouse when using Qt, as Qt grabs and releases it sensibly. In particular, Qt grabs the mouse when a mouse button is pressed and keeps it until the last button is released..PPNote that only visible widgets can grab mouse input. If isVisible() returns FALSE for a widget, that widget cannot call grabMouse()..PPSee also releaseMouse(), grabKeyboard(), releaseKeyboard(), grabKeyboard(), and focusWidget()..SH "void QWidget::grabMouse ( const QCursor & cursor )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPGrabs the mouse input and changes the cursor shape..PPThe cursor will assume shape \fIcursor\fR (for as long as the mouse focus is grabbed) and this widget will be the only one to receive mouse events until releaseMouse() is called()..PP\fBWarning:\fR Grabbing the mouse might lock the terminal..PPSee also releaseMouse(), grabKeyboard(), releaseKeyboard(), and cursor..SH "bool QWidget::hasFocus () const"Returns TRUE if this widget (or its focus proxy) has the keyboard input focus; otherwise returns FALSE. See the "focus" property for details..SH "bool QWidget::hasMouse () const"Returns TRUE if the widget is under the mouse cursor; otherwise returns FALSE. See the "underMouse" property for details..SH "bool QWidget::hasMouseTracking () const"Returns TRUE if mouse tracking is enabled for the widget; otherwise returns FALSE. See the "mouseTracking" property for details..SH "int QWidget::height () const"Returns the height of the widget excluding any window frame. See the "height" property for details..SH "int QWidget::heightForWidth ( int w ) const\fC [virtual]\fR"Returns the preferred height for this widget, given the width \fIw\fR. The default implementation returns 0, indicating that the preferred height does not depend on the width..PP\fBWarning:\fR Does not look at the widget's layout..PPReimplemented in QMenuBar and QTextEdit..SH "void QWidget::hide ()\fC [virtual slot]\fR"Hides the widget..PPYou almost never have to reimplement this function. If you need to do something after a widget is hidden, use hideEvent() instead..PPSee also hideEvent(), hidden, show(), showMinimized(), visible, and close()..PPExamples:.)l mdi/application.cpp, popup/popup.cpp, progress/progress.cpp, scrollview/scrollview.cpp, and xform/xform.cpp..PPReimplemented in QMenuBar..SH "void QWidget::hideEvent ( QHideEvent * )\fC [virtual protected]\fR"This event handler can be reimplemented in a subclass to receive widget hide events..PPHide events are sent to widgets immediately after they have been hidden..PPSee also event() and QHideEvent..PPReimplemented in QScrollBar..SH "const QPixmap * QWidget::icon () const"Returns the widget's icon. See the "icon" property for details..SH "QString QWidget::iconText () const"Returns the widget's icon text. See the "iconText" property for details..SH "void QWidget::iconify ()\fC [slot]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..SH "void QWidget::imComposeEvent ( QIMEvent * e )\fC [virtual protected]\fR"This event handler, for event \fIe\fR, can be reimplemented in a subclass to receive Input Method composition events. This handler is called when the user has entered some text using an Input Method..PPThe default implementation calls e->ignore(), which rejects the Input Method event. See the QIMEvent documentation for more details..PPSee also event() and QIMEvent..SH "void QWidget::imEndEvent ( QIMEvent * e )\fC [virtual protected]\fR"This event handler, for event \fIe\fR, can be reimplemented in a subclass to receive Input Method composition events. This handler is called when the user has finished inputting text via an Input Method..PPThe default implementation calls e->ignore(), which rejects the Input Method event. See the QIMEvent documentation for more details..PPSee also event() and QIMEvent..SH "void QWidget::imStartEvent ( QIMEvent * e )\fC [virtual protected]\fR"This event handler, for event \fIe\fR, can be reimplemented in a subclass to receive Input Method composition events. This handler is called when the user begins entering text using an Input Method..PPThe default implementation calls e->ignore(), which rejects the Input Method event. See the QIMEvent documentation for more details..PPSee also event() and QIMEvent..SH "bool QWidget::isActiveWindow () const"Returns TRUE if this widget is the active window; otherwise returns FALSE. See the "isActiveWindow" property for details..SH "bool QWidget::isDesktop () const"Returns TRUE if the widget is a desktop widget, i.e. represents the desktop; otherwise returns FALSE. See the "isDesktop" property for details..SH "bool QWidget::isDialog () const"Returns TRUE if the widget is a dialog widget; otherwise returns FALSE. See the "isDialog" property for details..SH "bool QWidget::isEnabled () const"Returns TRUE if the widget is enabled; otherwise returns FALSE. See the "enabled" property for details..SH "bool QWidget::isEnabledTo ( QWidget * ancestor ) const"Returns TRUE if this widget would become enabled if \fIancestor\fR is enabled; otherwise returns FALSE..PPThis is the case if neither the widget itself nor every parent up to but excluding \fIancestor\fR has been explicitly disabled..PPisEnabledTo(0) is equivalent to isEnabled()..PPSee also enabled and enabled..SH "bool QWidget::isEnabledToTLW () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis function is deprecated. It is equivalent to isEnabled().SH "bool QWidget::isFocusEnabled () const"Returns TRUE if the widget accepts keyboard focus; otherwise returns FALSE. See the "focusEnabled" property for details..SH "bool QWidget::isFullScreen () const"Returns TRUE if the widget is full screen; otherwise returns FALSE. See the "fullScreen" property for details..SH "bool QWidget::isHidden () const"Returns TRUE if the widget is explicitly hidden; otherwise returns FALSE. See the "hidden" property for details..SH "bool QWidget::isMaximized () const"Returns TRUE if this widget is maximized; otherwise returns FALSE. See the "maximized" property for details..SH "bool QWidget::isMinimized () const"Returns TRUE if this widget is minimized (iconified); otherwise returns FALSE. See the "minimized" property for details..SH "bool QWidget::isModal () const"Returns TRUE if the widget is a modal widget; otherwise returns FALSE. See the "isModal" property for details..SH "bool QWidget::isPopup () const"Returns TRUE if the widget is a popup widget; otherwise returns FALSE. See the "isPopup" property for details..SH "bool QWidget::isShown () const"Returns TRUE if the widget is shown; otherwise returns FALSE. See the "shown" property for details..SH "bool QWidget::isTopLevel () const"Returns TRUE if the widget is a top-level widget; otherwise returns FALSE. See the "isTopLevel" property for details..SH "bool QWidget::isUpdatesEnabled () const"Returns TRUE if updates are enabled; otherwise returns FALSE. See the "updatesEnabled" property for details..SH "bool QWidget::isVisible () const"Returns TRUE if the widget is visible; otherwise returns FALSE. See the "visible" property for details..SH "bool QWidget::isVisibleTo ( QWidget * ancestor ) const"Returns TRUE if this widget would become visible if \fIancestor\fR is shown; otherwise returns FALSE..PPThe TRUE case occurs if neither the widget itself nor any parent up to but excluding \fIancestor\fR has been explicitly hidden..PPThis function will still return TRUE if the widget is obscured by other windows on the screen, but could be physically visible if it or they were to be moved..PPisVisibleTo(0) is identical to isVisible()..PPSee also show(), hide(), and visible..SH "bool QWidget::isVisibleToTLW () const"\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code..PPThis function is deprecated. It is equivalent to isVisible().SH "void QWidget::keyPressEvent ( QKeyEvent * e )\fC [virtual protected]\fR"This event handler, for event \fIe\fR, can be reimplemented in a subclass to receive key press events for the widget..PPA widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event..PPIf you reimplement this handler, it is very important that you ignore() the event if you do not understand it, so that the widget's parent can interpret it..PPThe default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored..PPSee also keyReleaseEvent(), QKeyEvent::ignore(), focusPolicy, focusInEvent(), focusOutEvent(), event(), and QKeyEvent..PPExample: picture/picture.cpp..PPReimplemented in QLineEdit and QTextEdit..SH "void QWidget::keyReleaseEvent ( QKeyEvent * e )\fC [virtual protected]\fR"This event handler, for event \fIe\fR, can be reimplemented in a subclass to receive key release events for the widget..PPA widget must accept focus initially and have focus in order to receive a key release event..PPIf you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it..PPThe default implementation ignores the event..PPSee also keyPressEvent(), QKeyEvent::ignore(), focusPolicy, focusInEvent(), focusOutEvent(), event(), and QKeyEvent..SH "QWidget * QWidget::keyboardGrabber ()\fC [static]\fR"Returns the widget that is currently grabbing the keyboard input..PPIf no widget in this application is currently grabbing the keyboard, 0 is returned..PPSee also grabMouse() and mouseGrabber()..SH "QLayout * QWidget::layout () const"Returns the layout engine that manages the geometry of this widget's children..PPIf the widget does not have a layout, layout() returns 0..PPSee also sizePolicy..PPExamples:.)l chart/optionsform.cpp and fonts/simple-qfont-demo/viewer.cpp..SH "void
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -