Reputation: 861
Is it possible to connect a signal of class A to its own slot
Example as connect(objecta1, Signala1,objecta1,slota1)
Upvotes: 0
Views: 213
Reputation: 1110
Yes, it's very simple for example a QTimer:
myClass::myClass(QObject * parent):QObject(parent) {
timer = new QTimer();
timer->setSingleShot(true);
connect(timer, SIGNAL(timeout()), this, SLOT(myClassTimeout() ));
timer->start(1000);
}
Then you have
void myClass::myClassTimeout() {
//...
}
Upvotes: 0
Reputation: 6732
Yes, a class can react to its own signals. Be careful to not emit the signal from the triggered slots though.
Upvotes: 3