Error Connecting timer to slot <RESOLVED>
-
I am trying to connect to a slot with a timer. The line where I attempt to make the connection is:
connect(m_trigPullTimer, SIGNAL(timeout()), this, SLOT(updateFiringReload()));In the header file I have the following:
private slots:
void updateFiringReload();When I run the program and it hits the connect line I get the following error.
QObject::connect: No such slot QWidget::updateFiringReload()Where am I going wrong?
-
@Bear35645 Hi, you created the class definition with the according
slots:
line in the same class and inserted theQ_OBJECT
macro?
Example:#ifndef __main_hpp #define __main_hpp #include <QDebug> #include <QTimer> #include <QCoreApplication> class TimerTest : public QObject { Q_OBJECT public: TimerTest(); private: QTimer *t; public slots: void updateFiringReload(); }; #endif
and the implementation:
#include "main.hpp" int main( int argc, char *argv[] ) { QCoreApplication app(argc, argv); TimerTest t; return app.exec(); } TimerTest::TimerTest() { t = new QTimer(this); connect( t, SIGNAL(timeout()), this, SLOT(updateFiringReload()) ); t->start(1000); } void TimerTest::updateFiringReload() { qDebug() << "Test"; }