Qt World Summit: Register Today!

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?

  • is updateFiringReload defined in "this" class??

    seems that this is a QWidget

  • @Bear35645 Hi, you created the class definition with the according slots: line in the same class and inserted the Q_OBJECT macro?

    #ifndef __main_hpp
    #define __main_hpp
    #include <QDebug>
    #include <QTimer>
    #include <QCoreApplication>
    class TimerTest : public QObject {
        QTimer *t;
      public slots:
        void updateFiringReload();

    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()) );
    void TimerTest::updateFiringReload() {
      qDebug() << "Test";

  • @mcosta Yes it is defined in the class. The class is derived from QWidget.

  • @simow I did forget the Q_OBJECT macro. However now when I attempt to compile I am getting an error C:\Users\kbrooks\Work\MAST\r2coverlays.cpp:12: error: undefined reference to `vtable for R2COverlays' on my constructor.

  • @Bear35645 One complete rebuild, please using make -B.

  • @simow Thank you Sir. You have been a great help.

  • @Bear35645 You are welcome. Any time again. :)

Log in to reply