Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error Connecting timer to slot <RESOLVED>
Forum Updated to NodeBB v4.3 + New Features

Error Connecting timer to slot <RESOLVED>

Scheduled Pinned Locked Moved General and Desktop
qt5.4qtimer
8 Posts 3 Posters 2.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Bear35645B Offline
    Bear35645B Offline
    Bear35645
    wrote on last edited by Bear35645
    #1

    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?

    simowS 1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by mcosta
      #2

      is updateFiringReload defined in "this" class??

      seems that this is a QWidget

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      Bear35645B 1 Reply Last reply
      0
      • Bear35645B Bear35645

        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?

        simowS Offline
        simowS Offline
        simow
        wrote on last edited by simow
        #3

        @Bear35645 Hi, you created the class definition with the according slots: line in the same class and inserted the Q_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";
        }
        

        Let's Try To Negotiate!

        Bear35645B 1 Reply Last reply
        1
        • M mcosta

          is updateFiringReload defined in "this" class??

          seems that this is a QWidget

          Bear35645B Offline
          Bear35645B Offline
          Bear35645
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • simowS simow

            @Bear35645 Hi, you created the class definition with the according slots: line in the same class and inserted the Q_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";
            }
            
            Bear35645B Offline
            Bear35645B Offline
            Bear35645
            wrote on last edited by
            #5

            @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.

            simowS 1 Reply Last reply
            0
            • Bear35645B Bear35645

              @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.

              simowS Offline
              simowS Offline
              simow
              wrote on last edited by
              #6

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

              Let's Try To Negotiate!

              Bear35645B 1 Reply Last reply
              0
              • simowS simow

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

                Bear35645B Offline
                Bear35645B Offline
                Bear35645
                wrote on last edited by
                #7

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

                simowS 1 Reply Last reply
                0
                • Bear35645B Bear35645

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

                  simowS Offline
                  simowS Offline
                  simow
                  wrote on last edited by
                  #8

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

                  Let's Try To Negotiate!

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved