📄 qwidget.3qt
字号:
Reimplemented in QButton, QPopupMenu, QTable, QMenuBar, QComboBox, QDial, QTabBar, QTextView, QGroupBox, QSlider, QRadioButton, QListView, QPushButton, QLineEdit, QListBox and QMultiLineEdit..SH "bool QWidget::focusNextPrevChild ( bool next ) \fC[virtual protected]\fR"Finds a new widget to give the keyboard focus to, as appropriate for Tab/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, "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/first..PPChild widgets call focusNextPrevChild() on their parent widgets, and only the top-level widget will thus make the choice of 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()..PPReimplemented in QScrollView, QButton, QMultiLineEdit and QPopupMenu..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(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event() and QFocusEvent..PPReimplemented in QTable, QListView, QTabBar, QPopupMenu, QTextView, QSlider, QLineEdit, QMenuBar, QDial, QButton, QMultiLineEdit, QPushButton and QListBox..SH "QWidget::FocusPolicy QWidget::focusPolicy() const"Returns \fCQWidget::TabFocus\fR if the widget accepts focus by tabbing, \fCQWidget::ClickFocus\fR if the widget accepts focus by clicking, \fCQWidget::StrongFocus\fR if it accepts both and \fCQWidget::NoFocus\fR if it does not accept focus at all..PPSee also isFocusEnabled(), setFocusPolicy(), focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent() and isEnabled()..SH "QWidget * QWidget::focusProxy () const"Returns a pointer to 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..PPfontInfo() tells you what font is actually being used..PPAs long as no special font has been set, this is either a special font for the widget class, the parent's font or - if this widget is a toplevel widget - the default application font..PPSee also setFont(), fontInfo(), fontMetrics() and QApplication::font()..PPExamples:.(lmenu/menu.cpp xform/xform.cpp grapher/grapher.cpp.)l.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 setFont(), font(), update() and updateGeometry()..PPReimplemented in QLabel, QMenuBar and QGroupBox..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 setFont()..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 setFont()..PPExamples:.(ldrawdemo/drawdemo.cpp qmag/qmag.cpp xform/xform.cpp.)l.SH "QWidget::PropagationMode QWidget::fontPropagation() const"\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..PPThe return value is meaningless.PPSee also setFontPropagation()..SH "const QColor & QWidget::foregroundColor () const"Returns the foreground color of this widget..PPThe foreground color is also accessible as colorGroup().foreground()..PPSee also backgroundColor() and colorGroup()..SH "QRect QWidget::frameGeometry () const"Returns the geometry of the widget, relative to its parent and including the window frame..PPSee the Window Geometry documentation for an overview of geometry issues with top-level widgets..PPSee also geometry(), x(), y() and pos()..SH "QSize QWidget::frameSize () const"Returns the size of the window system frame (for top level widgets)..SH "const QRect & QWidget::geometry () const"Returns the geometry of the widget, relative to its parent widget and excluding the window frame..PPSee the Window Geometry documentation for an overview of geometry issues with top-level widgets..PPSee also frameGeometry(), size() and rect()..PPExamples:.(lqmag/qmag.cpp.)l.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 all keyboard input..PPThis widget will receive all keyboard events, independent of the active window..PP\fBWarning:\fR Grabbing the keyboard might lock the terminal..PPSee also releaseKeyboard(), grabMouse() and releaseMouse()..SH "void QWidget::grabMouse ()"Grabs the mouse input..PPThis widget will be the only one to receive mouse events until releaseMouse() is called..PP\fBWarning:\fR Grabbing the mouse might lock the terminal..PPIt is almost never necessary to grab the mouse when using Qt since Qt grabs and releases it sensibly. In particular, Qt grabs the mouse when a button is pressed and keeps it until the last button is released..PPBeware that only widgets actually shown on the screen may grab the mouse input..PPSee also releaseMouse(), grabKeyboard() and releaseKeyboard()..SH "void QWidget::grabMouse ( const QCursor & cursor )"Grabs 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 setCursor()..PPExamples:.(lqmag/qmag.cpp.)l.SH "bool QWidget::hasFocus () const"Returns TRUE if this widget (or its focus proxy) has the keyboard input focus, otherwise FALSE..PPEquivalent to \fCqApp->focusWidget() == this\fR..PPSee also setFocus(), clearFocus(), setFocusPolicy() and QApplication::focusWidget()..SH "bool QWidget::hasMouseTracking () const"Returns TRUE if mouse tracking is enabled for this widget, or FALSE if mouse tracking is disabled..PPSee also setMouseTracking()..SH "int QWidget::height () const"Returns the height of the widget, excluding the window frame..PPSee the Window Geometry documentation for an overview of geometry issues with top-level widgets..PPSee also geometry(), width() and size()..PPExamples:.(ldrawdemo/drawdemo.cpp qmag/qmag.cpp xform/xform.cpp grapher/grapher.cpp.)l.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 QLabel, QMenuBar and QTextView..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 isHhideEvent(), isHidden(), show(), showMinimized(), isVisible() and close()..PPExamples:.(lscrollview/scrollview.cpp progress/progress.cpp xform/xform.cpp popup/popup.cpp.)l.PPReimplemented in QToolBar, QMenuBar, QDialog and QPopupMenu..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 right after they have been hidden..PPSee also event() and QHideEvent..SH "const QPixmap * QWidget::icon () const"Returns the widget icon pixmap, or null if no icon has been set..PPSee also setIcon(), iconText() and caption()..SH "QString QWidget::iconText () const"Returns the widget icon text. If no icon text has been set (common for child widgets), this functions returns a null string..PPSee also setIconText(), icon(), caption() and QString::isNull()..SH "bool QWidget::isActiveWindow () const"Returns TRUE if this widget is in the active window, i.e. the window that has keyboard focus..PPWhen popup windows are visible, this function returns TRUE for both the active window and the popup..PPSee also setActiveWindow() and QApplication::activeWindow()..SH "bool QWidget::isDesktop () const"Returns TRUE if the widget is a desktop widget, otherwise FALSE..PPA desktop widget is also a top-level widget..PPSee also isTopLevel() and QApplication::desktop()..SH "bool QWidget::isEnabled () const"Returns TRUE if the widget is enabled, or FALSE if it is disabled..PPSee also setEnabled()..SH "bool QWidget::isEnabledTo ( QWidget * ancestor ) const"Returns TRUE if this widget would become enabled if \fIancestor\fR is enabled..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 setEnabled() and isEnabled()..SH "bool QWidget::isEnabledToTLW () const"\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..PPThis function is deprecated. It is equivalent to isEnabled().PPSee also setEnabled() and isEnabled()..SH "bool QWidget::isFocusEnabled () const"Returns TRUE if the widget accepts keyboard focus, or FALSE if it does not..PPKeyboard focus is initially disabled (i.e. focusPolicy() == \fCQWidget::NoFocus).\fR.PPYou must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(\fCQWidget::StrongFocus).\fR.PPSee also setFocusPolicy(), focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent() and isEnabled()..SH "bool QWidget::isHidden () const"Returns TRUE if the widget is explicitly hidden, or FALSE if it is visible or would become visible if all its ancestors became visible..PPSee also hide(), show(), isVisible() and isVisibleTo()..SH "bool QWidget::isMaximized () const"Returns TRUE if this widget is a top-level widget that is maximized, or else FALSE..PPNote that due to limitations in some window-systems, this does not always report expected results (eg. if the user on X11 maximizes the window via the window manager, Qt has no way of telling this from any other resize). This will improve as window manager protocols advance..PPSee also showMaximized()..SH "bool QWidget::isMinimized () const"Returns TRUE if this widget is a top-level widget that is minimized (iconified), or else FALSE..PPSee also showMinimized(), isVisible(), show(), hide() and showNormal()..SH "bool QWidget::isModal () const"Returns TRUE if the widget is a modal widget, otherwise FALSE..PPA modal widget is also a top-level widget..PPSee also isTopLevel() and QDialog..SH "bool QWidget::isPopup () const"Returns TRUE if the widget is a popup widget, otherwise FALSE..PPA popup widget is created by specifying the widget flag \fCWType_Popup\fR to the widget constructor..PPA popup widget is also a top-level widget..PPSee also isTopLevel()..SH "bool QWidget::isTopLevel () const"Returns TRUE if the widget is a top-level widget, otherwise FALSE..PPA top-level widget is a widget which usually has a frame and a caption (title bar). Popup and desktop widgets are also top-level widgets..PPA top-level widgets can have a parent widget. It will then be grouped with its parent: deleted when the parent is deleted, minimized when the parent is minimized etc. If supported by the window manager, it will also have a common taskbar entry with its parent..PPQDialog and QMainWindow widgets are by default top-level, even if a parent widget is specified in the constructor. This behavior is specified by the \fCWType_TopLevel\fR widget flag..PPChild widgets are the opposite of top-level widgets..PPSee also topLevelWidget(), isModal(), isPopup(), isDesktop() and parentWidget()..SH "bool QWidget::isUpdatesEnabled () const"Returns TRUE if updates are enabled, otherwise FALSE..PPSee also setUpdatesEnabled()..SH "bool QWidget::isVisible () const"Returns TRUE if the widget itself is visible, or else FALSE..PPCalling show() sets the widget to visible status if all its parent widgets up to the toplevel widget are visible. If an ancestor is not visible, the widget won't become visible until all its ancestors are shown..PPCalling hide() hides a widget explicitly. An explicitly hidden widget will never become visible, even if all its ancestors become visible..PPIconified top-level widgets also have hidden status, as well as having isMinimized() return TRUE. Windows that live on another virtual desktop (on platforms that support this concept) also have hidden status..PPThis function returns TRUE if the widget currently is obscured by other windows on the screen, but would be visible if moved..PPA widget receives show- and hide events when its visibility status changes. Between a hide and a show event, there is no need in wasting any CPU on preparing or displaying information to the user. A video application, for example, might simply stop generating new frames..PPSee also show(), hide(), isHidden(), isVisibleTo(), isMinimized(), showEvent() and hideEvent()..SH "bool QWidget::isVisibleTo ( QWidget * ancestor ) const"Returns TRUE if this widget would become visible if \fIancestor\fR is shown..PPThis is the case if neither the widget itself nor every parent up to but excluding \fIancestor\fR has been explicitly hidden..PPThis function returns TRUE if the widget it is obscured by other windows on the screen, but would be visible if moved..PPisVisibleTo(0) is very similar to isVisible(), with the exception that it does not cover the iconfied-case or the situation where the window lives on another virtual desktop..PPSee also show(), hide() and isVisible()..SH "bool QWidget::isVisibleToTLW () const"\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..PPThis function is deprecated. It is equivalent to isVisible().PPSee also show(), hide() and isVisible()..SH "void QWidget::keyPressEvent ( QKeyEvent * e ) \fC[virtual protected]\fR"This event handler 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 you hit escape. Otherwise the event is ignored..PPSee also keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event() and QKeyEvent..PPReimplemented in QSlider, QMultiLineEdit, QMessageBox, QButton, QTable, QPopupMenu, QTabBar, QDialog, QMenuBar, QDial, QScrollBar, QListBox, QTextView, QLineEdit, QComboBox, QFileDialog, QListView and QTextBrowser..SH "void QWidget::keyReleaseEvent ( QKeyEvent * e ) \fC[virtual protected]\fR"This event handler 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..PPI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -