📄 qcustomevent.3qt
字号:
'\" t.TH QCustomEvent 3qt "9 December 2002" "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 NAMEQCustomEvent \- Support for custom events.SH SYNOPSIS\fC#include <qevent.h>\fR.PPInherits QEvent..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQCustomEvent\fR ( int type )".br.ti -1c.BI "\fBQCustomEvent\fR ( Type type, void * data )".br.ti -1c.BI "void * \fBdata\fR () const".br.ti -1c.BI "void \fBsetData\fR ( void * data )".br.in -1c.SH DESCRIPTIONThe QCustomEvent class provides support for custom events..PPQCustomEvent is a generic event class for user-defined events. User defined events can be sent to widgets or other QObject instances using QApplication::postEvent() or QApplication::sendEvent(). Subclasses of QWidget can easily receive custom events by implementing the QWidget::customEvent() event handler function..PPQCustomEvent objects should be created with a type ID that uniquely identifies the event type. To avoid clashes with the Qt-defined events types, the value should be at least as large as the value of the "User" entry in the QEvent::Type enum..PPQCustomEvent contains a generic void* data member that may be used for transferring event-specific data to the receiver. Note that since events are normally delivered asynchronously, the data pointer, if used, must remain valid until the event has been received and processed..PPQCustomEvent can be used as-is for simple user-defined event types, but normally you will want to make a subclass of it for your event types. In a subclass, you can add data members that are suitable for your event type..PPExample:.PP.nf.br class ColorChangeEvent : public QCustomEvent.br {.br public:.br ColorChangeEvent( QColor color ).br : QCustomEvent( 65432 ), c( color ) {}.br QColor color() const { return c; }.br private:.br QColor c;.br };.br.br // To send an event of this custom event type:.br.br ColorChangeEvent* ce = new ColorChangeEvent( blue );.br QApplication::postEvent( receiver, ce ); // Qt will delete it when done.br.br // To receive an event of this custom event type:.br.br void MyWidget::customEvent( QCustomEvent * e ).br {.br if ( e->type() == 65432 ) { // It must be a ColorChangeEvent.br ColorChangeEvent* ce = (ColorChangeEvent*)e;.br newColor = ce->color();.br }.br }.br.fi.PPSee also QWidget::customEvent(), QApplication::notify(), and Event Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QCustomEvent::QCustomEvent ( int type )"Constructs a custom event object with event type \fItype\fR. The value of \fItype\fR must be at least as large as QEvent::User. The data pointer is set to 0..SH "QCustomEvent::QCustomEvent ( Type type, void * data )"Constructs a custom event object with the event type \fItype\fR and a pointer to \fIdata\fR. (Note that any int value may safely be cast to QEvent::Type)..SH "void * QCustomEvent::data () const"Returns a pointer to the generic event data..PPSee also setData()..SH "void QCustomEvent::setData ( void * data )"Sets the generic data pointer to \fIdata\fR..PPSee also data()..SH "SEE ALSO".BR http://doc.trolltech.com/qcustomevent.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qcustomevent.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -