Q3Signal Class Reference |
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 |
The Q3Signal class can be used to send signals for classes that don't inherit QObject.
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); }
Constructs a signal object called name, with the parent object parent. These arguments are passed directly to QObject.
Destroys the signal. All connections are removed, as is the case with all QObjects.
Emits the signal. If the platform supports QVariant and a parameter has been set with setValue(), this value is passed in the signal.
Connects the signal to member in object receiver. Returns true if the connection is successful.
See also disconnect() and QObject::connect().
Disonnects the signal from member in object receiver. Returns true if the connection existed and the disconnect was successful.
See also connect() and QObject::disconnect().
Sets the signal's parameter to value
See also value().
Returns the signal's parameter
See also setValue().
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.6-snapshot | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com