Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QSignal Class Reference

The QSignal class can be used to send signals for classes that do not inherit QObject. More...

#include <QSignal>

Public Functions


Detailed Description

The QSignal class can be used to send signals for classes that do not inherit QObject.

If you want to send signals from a class that does not inherit QObject, you can create an internal QSignal<T> object to emit the signal. T is the type of the signal's argument, and it can be void. You must also provide a function that connects the signal to an outside object slot.

In general, we recommend inheriting QObject instead, since QObject provides much more functionality.

Example:

    #include <qsignal.h>

    class MyClass
    {
    public:
        MyClass();
        ~MyClass();

        void doSomething();

        void connect(QObject *receiver, const char *member);

    private:
        QSignal<void> sig;
    };

    void MyClass::doSomething()
    {
        // ... does something

        sig->activate(); // emits the signal
    }

    void MyClass::connect(QObject *receiver, const char *member)
    {
        sig->connect(receiver, member);
    }

Member Function Documentation

QSignal::QSignal ()

Constructs a signal object

QSignal::~QSignal ()

Destroys the signal. All connections are removed.

void QSignal::activate ( const T & t )

Emits the signal with value t.

bool QSignal::connect ( const QObject * receiver, const char * member, Qt::ConnectionType type = Qt::AutoConnection )

Connects the signal to member in object receiver using the given connection type.

See also disconnect().

bool QSignal::disconnect ( const QObject * receiver, const char * member = 0 )

Disconnects the signal from member in object receiver.

See also connect().


Copyright © 2004 Trolltech Trademarks
Qt 4.0.0-b1