How to override timeout() signal of qtimer or any other signal in our class?
-
How to override timeout() signal of qtimer or any other signal in our class or any other signal.
Also how to use both overridden signal and base signal ? -
Hi @Piyush_Ashtikar, and welcome to the Qt Dev Net!
How to override timeout() signal of qtimer or any other signal in our class or any other signal.
Also how to use both overridden signal and base signal ?What do you mean by "override a signal"? Signals don't contain any functions -- they only call slots.
Do you mean "override a slot"?
-
Hi there,
I'm not completely sure what you are asking. But if I'm understanding you correctly, you
want to implement the timeout() signal in your own way? I would suggest sub-classing the
QTimer object.#include <QTimer> class CustomTimer : public QTimer { Q_OBJECT public: explicit CustomTimer(QObject *parent = 0); signals: void customSignal(/*parameters*/); public slots: void emitCustomSignal(); }; CustomTimer::CustomTimer(QObject *parent) : QTimer(parent) { connect(this, SIGNAL(timeout()), this, SLOT(emitCustomSignal())); } void CustomTimer::emitCustomSignal() { emit customSignal(/*parameters*/); }