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

📄 qwidget.3qt

📁 Trolltech公司发布的基于C++图形开发环境
💻 3QT
📖 第 1 页 / 共 5 页
字号:
This enum used to determine how fonts and palette changes are propagated to children of a widget..SH MEMBER FUNCTION DOCUMENTATION.SH "QWidget::QWidget ( QWidget * parent=0, const char * name=0, WFlags f=0 )"Constructs a widget which is a child of \fIparent,\fR with the name \fIname\fR and widget flags set to \fIf.\fR.PPIf \fIparent\fR is 0, the new widget becomes a top-level window. If \fIparent\fR is another widget, this widget becomes a child window inside \fIparent.\fR The new widget is deleted when \fIparent\fR is..PPThe \fIname\fR is sent to the QObject constructor..PPThe widget flags argument \fIf\fR is normally 0, but it can be set to customize the window frame of a top-level widget (i.e. \fIparent\fR must be zero). To customize the frame, set the \fCWStyle_Customize\fR flag OR'ed with any of the Qt::WidgetFlags..PPNote that the X11 version of Qt may not be able to deliver all combinations of style flags on all systems. This is because on X11, Qt can only ask the window manager, and the window manager can override the application's settings. On Windows, Qt can set whatever flags you want..PPExample:.PP.nf.br    QLabel *spashScreen = new QLabel( 0, "mySplashScreen",.br                                  WStyle_Customize | WStyle_NoBorder |.br                                  WStyle_Tool );.fi.SH "QWidget::~QWidget ()"Destructs the widget..PPAll children of this widget are deleted first. The application exits if this widget is (was) the main widget..SH "bool QWidget::acceptDrops () const"Returns TRUE if drop events are enabled for this widget..PPSee also setAcceptDrops()..SH "void QWidget::adjustSize () \fC[virtual]\fR"Adjusts the size of the widget to fit the contents..PPUses sizeHint() if valid (i.e if the size hint's width and height are equal to or greater than 0), otherwise sets the size to the children rectangle (the union of all child widget geometries)..PPSee also sizeHint() and childrenRect()..PPExamples:.(lxform/xform.cpp.)l.PPReimplemented in QMessageBox..SH "bool QWidget::autoMask () const"Returns whether or not the widget has the auto mask feature enabled..PPSee also setAutoMask(), updateMask(), setMask() and clearMask()..SH "const QColor & QWidget::backgroundColor () const"Returns the background color of this widget, which is normally set implicitly by setBackgroundMode(), but can also be set explicitly by setBackgroundColor()..PPIf there is a background pixmap (set using setBackgroundPixmap()), then the return value of this function is indeterminate..PPSee also setBackgroundColor(), foregroundColor(), colorGroup() and palette()..PPExamples:.(lxform/xform.cpp grapher/grapher.cpp.)l.SH "void QWidget::backgroundColorChange ( const QColor & oldBackgroundColor ) \fC[virtual protected]\fR"This virtual function is called from setBackgroundColor(). \fIoldBackgroundColor\fR is the previous background color; you can get the new background color from backgroundColor()..PPReimplement this function if your widget needs to know when its background color changes. You will almost certainly need to call this implementation of the function..PPSee also setBackgroundColor(), backgroundColor(), setPalette(), repaint() and update()..SH "QWidget::BackgroundMode QWidget::backgroundMode() const"Returns the mode most recently set by setBackgroundMode(). The default is PaletteBackground..PPSee also BackgroundMode and setBackgroundMode()..SH "QWidget::BackgroundOrigin QWidget::backgroundOrigin() const"Returns the current background origin..PPSee also setBackgroundOrigin()..SH "const QPixmap * QWidget::backgroundPixmap () const"Returns the background pixmap if one has been set. If the widget has backgroundMode() NoBackground, the return value is a pixmap for which QPixmao:isNull() is true. If the widget has no pixmap is the background, the return value is a null pointer..PPSee also setBackgroundPixmap() and setBackgroundMode()..SH "void QWidget::backgroundPixmapChange ( const QPixmap & oldBackgroundPixmap ) \fC[virtual protected]\fR"This virtual function is called from setBackgroundPixmap(). \fIoldBackgroundPixmap\fR is the previous background pixmap; you can get the new background pixmap from backgroundPixmap()..PPReimplement this function if your widget needs to know when its background pixmap changes. You will almost certainly need to call this implementation of the function..PPSee also setBackgroundPixmap(), backgroundPixmap(), repaint() and update()..SH "QSize QWidget::baseSize () const"Returns the widget base size.PPThe base size is used to calculate a proper widget size in case the widget defines sizeIncrement()..PPSee also setBaseSize() and setSizeIncrement()..SH "QString QWidget::caption () const"Returns the widget caption. If no caption has been set (common for child widgets), this functions returns a null string..PPSee also setCaption(), icon(), iconText() and QString::isNull()..PPExamples:.(li18n/main.cpp.)l.SH "QRect QWidget::childrenRect () const"Returns the bounding rectangle of the widget's children..PPExplicitely hidden children are excluded..PPSee also childrenRegion()..SH "QRegion QWidget::childrenRegion () const"Returns the combined region of the widget's children geometry()..PPExplicitely hidden children are excluded..PPSee also childrenRect()..SH "void QWidget::clearFocus () \fC[slot]\fR"Takes keyboard input focus from the widget..PPIf the widget has active focus, a focus out event is sent to this widget to tell it that it is about to lose the focus..PPThis widget must enable focus setting in order to get the keyboard input focus, i.e. it must call setFocusPolicy()..PPSee also hasFocus(), setFocus(), focusInEvent(), focusOutEvent(), setFocusPolicy() and QApplication::focusWidget()..SH "void QWidget::clearMask ()"Removes any mask set by setMask()..PPSee also setMask()..SH "void QWidget::clearWFlags ( WFlags f ) \fC[protected]\fR"Clears the widget flags \fIf.\fR.PPWidget flags are a combination of Qt::WidgetFlags..PPSee also testWFlags(), getWFlags() and setWFlags()..SH "bool QWidget::close () \fC[slot]\fR"Closes this widget. Returns TRUE if the widget was closed, otherwise FALSE..PPFirst it sends the widget a QCloseEvent. The widget is hidden if it accepts the close event. The default implementation of QWidget::closeEvent() accepts the close event..PPThe QApplication::lastWindowClosed() signal is emitted when the last visible top level widget is closed..PPSee also close(bool)..PPExamples:.(lpopup/popup.cpp.)l.SH "bool QWidget::close ( bool alsoDelete ) \fC[virtual]\fR"Closes this widget. Returns TRUE if the widget was closed, otherwise FALSE..PPIf \fIalsoDelete\fR is TRUE or the widget has the \fCWDestructiveClose\fR widget flag, the widget is also deleted. The widget can prevent itself from being closed by rejecting the QCloseEvent it gets..PPThe QApplication::lastWindowClosed() signal is emitted when the last visible top level widget is closed..PPNote that closing the QApplication::mainWidget() terminates the application..PPSee also closeEvent(), QCloseEvent, hide(), QApplication::quit(), QApplication::setMainWidget() and QApplication::lastWindowClosed()..SH "void QWidget::closeEvent ( QCloseEvent * e ) \fC[virtual protected]\fR"This event handler can be reimplemented in a subclass to receive widget close events..PPThe default implementation calls e->accept(), which hides this widget. See the QCloseEvent documentation for more details..PPSee also event(), hide(), close() and QCloseEvent..PPReimplemented in QDialog, QProgressDialog and QPopupMenu..SH "const QColorGroup & QWidget::colorGroup () const"Returns the current color group of the widget palette..PPThe color group is determined by the state of the widget..PPA disabled widget returns the QPalette::disabled() color group, a widget in the window with keyboard focus returns the QPalette::active() color group, and all inactive widgets return the QPalette::inactive() color group..PPSee also palette() and setPalette()..SH "void QWidget::constPolish () const \fC[slot]\fR"Ensures that the widget is properly initialized by calling polish()..PPCall constPolish() from functions like sizeHint() that depends on the widget being initialized, and that may be called before show()..PP\fBWarning:\fR Do not call constPolish() on a widget from inside that widget's constructor..PPSee also polish()..SH "void QWidget::create ( WId window = 0, bool initializeWindow = TRUE, bool destroyOldWindow = TRUE ) \fC[virtual protected]\fR"Creates a new widget window if \fIwindow\fR is null, otherwise sets the widget's window to \fIwindow.\fR.PPInitializes the window (sets the geometry etc.) if \fIinitializeWindow\fR is TRUE. If \fIinitializeWindow\fR is FALSE, no initialization is performed. This parameter makes only sense if \fIwindow\fR is a valid window..PPDestroys the old window if \fIdestroyOldWindow\fR is TRUE. If \fIdestroyOldWindow\fR is FALSE, you are responsible for destroying the window yourself (using platform native code)..PPThe QWidget constructor calls create(0,TRUE,TRUE) to create a window for this widget..SH "const QCursor & QWidget::cursor () const"Returns the widget cursor. If no cursor has been set the parent widget's cursor is returned..PPSee also setCursor() and unsetCursor();..SH "void QWidget::customEvent ( QCustomEvent * ) \fC[virtual protected]\fR"This event handler can be reimplemented in a subclass to receive custom events. Custom events are user-defined events with a type value at least as large as the "User" item of the QEvent::Type enum, and is typically a QCustomEvent or QCustomEvent subclass..PPSee also event() and QCustomEvent..SH "bool QWidget::customWhatsThis () const \fC[virtual]\fR"Returns whether the widget wants to handle What's This help manually. The default implementation returns FALSE, which means the widget will not receive any events in Whats This mode..PPThe widget may leave Whats This mode by calling QWhatsThis::leaveWhatsThisMode(), with or without actually displaying any help text..PPYou may also reimplement customWhatsThis() if your widget is a so-called "passive interactor" that is supposed to work under all circumstances. Simply don't call QWhatsThis::leaveWhatsThisMode() in that case..PPSee also QWhatsThis::inWhatsThisMode() and QWhatsThis::leaveWhatsThisMode()..PPReimplemented in QPopupMenu and QMenuBar..SH "void QWidget::destroy ( bool destroyWindow = TRUE, bool destroySubWindows = TRUE ) \fC[virtual protected]\fR"Frees up window system resources. Destroys the widget window if \fIdestroyWindow\fR is TRUE..PPdestroy() calls itself recursively for all the child widgets, passing \fIdestroySubWindows\fR for the \fIdestroyWindow\fR parameter. To have more control over destruction of subwidgets, destroy subwidgets selectively first..PPThis function is usually called from the QWidget destructor..SH "void QWidget::dragEnterEvent ( QDragEnterEvent * ) \fC[virtual protected]\fR"This event handler is called when a drag is in progress and the mouse enters this widget..PPSee the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application..PPSee also QTextDrag, QImageDrag and QDragEnterEvent..PPReimplemented in QLineEdit and QMultiLineEdit..SH "void QWidget::dragLeaveEvent ( QDragLeaveEvent * ) \fC[virtual protected]\fR"This event handler is called when a drag is in progress and the mouse leaves this widget..PPSee the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application..PPSee also QTextDrag, QImageDrag and QDragLeaveEvent..PPReimplemented in QMultiLineEdit..SH "void QWidget::dragMoveEvent ( QDragMoveEvent * ) \fC[virtual protected]\fR"This event handler is called when a drag is in progress and the mouse enters this widget, and whenever it moves within the widget..PPSee the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application..PPSee also QTextDrag, QImageDrag and QDragMoveEvent..PPReimplemented in QMultiLineEdit..SH "void QWidget::drawText ( int x, int y, const QString & str )"Writes \fIstr\fR at position \fIx,y.\fR.PPThe \fIy\fR position is the base line position of the text. The text is drawn using the default font and the default foreground color..PPThis function is provided for convenience. You will generally get more flexible results and often higher speed by using a a painter instead..PPSee also setFont(), foregroundColor() and QPainter::drawText()..SH "void QWidget::drawText ( const QPoint & pos, const QString & str )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "void QWidget::dropEvent ( QDropEvent * ) \fC[virtual protected]\fR"This event handler is called when the drag is dropped on this widget..PPSee the Drag-and-drop documentation for an overview of how to provide drag-and-drop in your application..PPSee also QTextDrag, QImageDrag and QDropEvent..PPReimplemented in QMultiLineEdit and QLineEdit..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 setEnabled(), isEnabled(), repaint(), update() and visibleRect()..PPReimplemented in QListView and QButton..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()..PPReimplemented in QToolButton..SH "void QWidget::erase ( const QRegion & reg )"Erases the area defined by \fIreg,\fR without generating a paint event..PPChild widgets are not affected..PPExamples:.(ldrawlines/connect.cpp.)l.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 differs from the above function only in what argument(s) it accepts..PPThis version erases the entire widget..SH "void QWidget::erase ( const QRect & r )"This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts..SH "bool QWidget::event ( QEvent * e ) \fC[virtual protected]\fR"This is the main event handler. You may 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/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, or FALSE if nobody wanted the event..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 by the underlying window system, see qwindowdefs.h for the actual definition. If there is no widget with this identifier, a null pointer is returned..PPSee also wmapper() and winId()..SH "QFocusData * QWidget::focusData () \fC[protected]\fR"Returns a pointer to 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(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event() and QFocusEvent..PP

⌨️ 快捷键说明

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