1QCustomEvent(3qt)                                            QCustomEvent(3qt)
2
3
4

NAME

6       QCustomEvent - Support for custom events
7

SYNOPSIS

9       #include <qevent.h>
10
11       Inherits QEvent.
12
13   Public Members
14       QCustomEvent ( int type )
15       QCustomEvent ( Type type, void * data )
16       void * data () const
17       void setData ( void * data )
18

DESCRIPTION

20       The QCustomEvent class provides support for custom events.
21
22       QCustomEvent is a generic event class for user-defined events. User
23       defined events can be sent to widgets or other QObject instances using
24       QApplication::postEvent() or QApplication::sendEvent(). Subclasses of
25       QObject can easily receive custom events by implementing the
26       QObject::customEvent() event handler function.
27
28       QCustomEvent objects should be created with a type ID that uniquely
29       identifies the event type. To avoid clashes with the Qt-defined events
30       types, the value should be at least as large as the value of the "User"
31       entry in the QEvent::Type enum.
32
33       QCustomEvent contains a generic void* data member that may be used for
34       transferring event-specific data to the receiver. Note that since
35       events are normally delivered asynchronously, the data pointer, if
36       used, must remain valid until the event has been received and
37       processed.
38
39       QCustomEvent can be used as-is for simple user-defined event types, but
40       normally you will want to make a subclass of it for your event types.
41       In a subclass, you can add data members that are suitable for your
42       event type.
43
44       Example:
45
46           class ColorChangeEvent : public QCustomEvent
47           {
48           public:
49               ColorChangeEvent( QColor color )
50                   : QCustomEvent( 65432 ), c( color ) {}
51               QColor color() const { return c; }
52           private:
53               QColor c;
54           };
55           // To send an event of this custom event type:
56           ColorChangeEvent* ce = new ColorChangeEvent( blue );
57           QApplication::postEvent( receiver, ce );  // Qt will delete it when done
58           // To receive an event of this custom event type:
59           void MyWidget::customEvent( QCustomEvent * e )
60           {
61               if ( e->type() == 65432 ) {  // It must be a ColorChangeEvent
62                   ColorChangeEvent* ce = (ColorChangeEvent*)e;
63                   newColor = ce->color();
64               }
65           }
66
67       See also QWidget::customEvent(), QApplication::notify(), and Event
68       Classes.
69

MEMBER FUNCTION DOCUMENTATION

QCustomEvent::QCustomEvent ( int type )

72       Constructs a custom event object with event type type. The value of
73       type must be at least as large as QEvent::User. The data pointer is set
74       to 0.
75

QCustomEvent::QCustomEvent ( Type type, void * data )

77       Constructs a custom event object with the event type type and a pointer
78       to data. (Note that any int value may safely be cast to QEvent::Type).
79

void * QCustomEvent::data () const

81       Returns a pointer to the generic event data.
82
83       See also setData().
84

void QCustomEvent::setData ( void * data )

86       Sets the generic data pointer to data.
87
88       See also data().
89
90

SEE ALSO

92       http://doc.trolltech.com/qcustomevent.html
93       http://www.trolltech.com/faq/tech.html
94
96       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
97       license file included in the distribution for a complete license
98       statement.
99

AUTHOR

101       Generated automatically from the source code.
102

BUGS

104       If you find a bug in Qt, please report it as described in
105       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
106       help you. Thank you.
107
108       The definitive Qt documentation is provided in HTML format; it is
109       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
110       web browser. This man page is provided as a convenience for those users
111       who prefer man pages, although this format is not officially supported
112       by Trolltech.
113
114       If you find errors in this manual page, please report them to qt-
115       bugs@trolltech.com.  Please include the name of the manual page
116       (qcustomevent.3qt) and the Qt version (3.3.8).
117
118
119
120Trolltech AS                    2 February 2007              QCustomEvent(3qt)
Impressum