#include <q3signal.h>
Inheritance diagram for Q3Signal:


If you want to send signals from a class that does not inherit QObject, you can create an internal Q3Signal object to emit the signal. You must also provide a function that connects the signal to an outside object slot. This is how we used to implement signals in Qt 3's QMenuData class, which was not a QObject. In Qt 4, menus contain actions, which are QObjects.
In general, we recommend inheriting QObject instead. QObject provides much more functionality.
You can set a single QVariant parameter for the signal with setValue().
Note that QObject is a private base class of Q3Signal, i.e. you cannot call any QObject member functions from a Q3Signal object.
Example:
#include <q3signal.h> class MyClass { public: MyClass(); ~MyClass(); void doSomething(); void connect(QObject *receiver, const char *member); private: Q3Signal *sig; }; MyClass::MyClass() { sig = new Q3Signal; } MyClass::~MyClass() { delete sig; } void MyClass::doSomething() { // ... does something sig->activate(); // emits the signal } void MyClass::connect(QObject *receiver, const char *member) { sig->connect(receiver, member); }
Definition at line 34 of file q3signal.h.
Signals | |
| void | signal (const QVariant &) |
| void | intSignal (int) |
Public Member Functions | |
| Q3Signal (QObject *parent=0, const char *name=0) | |
| ~Q3Signal () | |
| bool | connect (const QObject *receiver, const char *member) |
| bool | disconnect (const QObject *receiver, const char *member=0) |
| void | activate () |
| bool | isBlocked () const |
| void | block (bool b) |
| void | setParameter (int value) |
| int | parameter () const |
| void | setValue (const QVariant &value) |
| QVariant | value () const |
Private Attributes | |
| QVariant | val |
| Q3Signal::Q3Signal | ( | QObject * | parent = 0, |
|
| const char * | name = 0 | |||
| ) |
| Q3Signal::~Q3Signal | ( | ) |
Destroys the signal. All connections are removed, as is the case with all QObjects.
Definition at line 110 of file q3signal.cpp.
| bool Q3Signal::connect | ( | const QObject * | receiver, | |
| const char * | member | |||
| ) |
Connects the signal to member in object receiver.
Definition at line 128 of file q3signal.cpp.
References QObject::connect(), intSignal(), intSignature(), SIGNAL, and signal().
Referenced by Q3Accel::connectItem().
00129 { 00130 #ifndef QT_NO_VARIANT 00131 if (intSignature(member)) 00132 #endif 00133 return QObject::connect((QObject *)this, SIGNAL(intSignal(int)), receiver, member); 00134 #ifndef QT_NO_VARIANT 00135 return QObject::connect((QObject *)this, SIGNAL(signal(QVariant)), 00136 receiver, member); 00137 #endif 00138 }
Here is the call graph for this function:

| bool Q3Signal::disconnect | ( | const QObject * | receiver, | |
| const char * | member = 0 | |||
| ) |
Disonnects the signal from member in object receiver.
Reimplemented from QObject.
Definition at line 146 of file q3signal.cpp.
References QObject::disconnect(), intSignal(), intSignature(), SIGNAL, and signal().
Referenced by Q3Accel::disconnectItem().
00147 { 00148 if (!member) 00149 return QObject::disconnect((QObject *)this, 0, receiver, member); 00150 #ifndef QT_NO_VARIANT 00151 if (intSignature(member)) 00152 #endif 00153 return QObject::disconnect((QObject *)this, SIGNAL(intSignal(int)), receiver, member); 00154 #ifndef QT_NO_VARIANT 00155 return QObject::disconnect((QObject *)this, SIGNAL(signal(QVariant)), 00156 receiver, member); 00157 #endif 00158 }
Here is the call graph for this function:

| void Q3Signal::activate | ( | ) |
Emits the signal. If the platform supports QVariant and a parameter has been set with setValue(), this value is passed in the signal.
Definition at line 189 of file q3signal.cpp.
References emit, intSignal(), signal(), QVariant::toInt(), and val.
Referenced by Q3AccelPrivate::activate(), and Q3AccelPrivate::activateAmbiguously().
00190 { 00191 #ifndef QT_NO_VARIANT 00192 /* Create this Q3GuardedPtr on this, if we get destroyed after the intSignal (but before the variant signal) 00193 we cannot just emit the signal (because val has been destroyed already) */ 00194 QPointer<Q3Signal> me = this; 00195 if(me) 00196 emit intSignal(val.toInt()); 00197 if(me) 00198 emit signal(val); 00199 #else 00200 emit intSignal(0); 00201 #endif 00202 }
Here is the call graph for this function:

| bool Q3Signal::isBlocked | ( | ) | const [inline] |
Returns true if the signal is blocked, or false if it is not blocked.
The signal is not blocked by default.
Definition at line 47 of file q3signal.h.
References QObject::signalsBlocked().
00047 { return QObject::signalsBlocked(); }
Here is the call graph for this function:

| void Q3Signal::block | ( | bool | b | ) | [inline] |
Blocks the signal if b is true, or unblocks the signal if b is false.
An activated signal disappears into hyperspace if it is blocked.
Definition at line 48 of file q3signal.h.
References QObject::blockSignals().
00048 { QObject::blockSignals(b); }
Here is the call graph for this function:

| void Q3Signal::setParameter | ( | int | value | ) |
| int Q3Signal::parameter | ( | ) | const |
Definition at line 234 of file q3signal.cpp.
References QVariant::toInt(), and val.
Here is the call graph for this function:

| void Q3Signal::setValue | ( | const QVariant & | value | ) |
| QVariant Q3Signal::value | ( | ) | const |
Returns the signal's parameter
Definition at line 216 of file q3signal.cpp.
References val.
Referenced by setValue().
00217 { 00218 return val; 00219 }
| void Q3Signal::signal | ( | const QVariant & | ) | [signal] |
Referenced by activate(), connect(), and disconnect().
| void Q3Signal::intSignal | ( | int | ) | [signal] |
Referenced by activate(), connect(), and disconnect().
QVariant Q3Signal::val [private] |
Definition at line 68 of file q3signal.h.
Referenced by activate(), parameter(), Q3Signal(), setParameter(), setValue(), and value().
1.5.1