
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3Signal class can be used to send signals for classes that don't inheritQObject.More...
| Header: | #include <Q3Signal> |
| Inherits: | QObject |
| Q3Signal(QObject * parent = 0, const char * name = 0) | |
| ~Q3Signal() | |
| void | activate() |
| bool | connect(const QObject * receiver, const char * member) |
| bool | disconnect(const QObject * receiver, const char * member = 0) |
| void | setValue(const QVariant & value) |
| QVariant | value() const |
TheQ3Signal class can be used to send signals for classes that don't inheritQObject.
If you want to send signals from a class that does not inheritQObject, you can create an internalQ3Signal 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'sQMenuData class, which was not aQObject. In Qt 4, menus contain actions, which areQObjects.
In general, we recommend inheritingQObject instead.QObject provides much more functionality.
You can set a singleQVariant parameter for the signal withsetValue().
Note thatQObject is aprivate base class ofQ3Signal, i.e. you cannot call anyQObject member functions from aQ3Signal object.
Example:
#include <q3signal.h>class MyClass{public: MyClass();~MyClass();void doSomething();void connect(QObject*receiver,constchar*member);private:Q3Signal*sig;};MyClass::MyClass(){ sig=newQ3Signal;}MyClass::~MyClass(){delete sig;}void MyClass::doSomething(){// ... does something sig->activate();// emits the signal}void MyClass::connect(QObject*receiver,constchar*member){ sig->connect(receiver, member);}
Constructs a signal object calledname, with the parent objectparent. These arguments are passed directly toQObject.
Destroys the signal. All connections are removed, as is the case with allQObjects.
Emits the signal. If the platform supportsQVariant and a parameter has been set withsetValue(), this value is passed in the signal.
Connects the signal tomember in objectreceiver. Returns true if the connection is successful.
See alsodisconnect() andQObject::connect().
Disonnects the signal frommember in objectreceiver. Returns true if the connection existed and the disconnect was successful.
See alsoconnect() andQObject::disconnect().
Sets the signal's parameter tovalue
See alsovalue().
Returns the signal's parameter
See alsosetValue().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.