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. QTimer will not connect
Forum Updated to NodeBB v4.3 + New Features

QTimer will not connect

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 701 Views
  • 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.
  • B Offline
    B Offline
    BKBK
    wrote on last edited by BKBK
    #1

    Yes, Qt3, novice programmer. Please try to accommodate typos as I cannot copy paste from my work computer to here. It does run but the connect fails. Found another thread here, same topic, but don’t have the same error as that one.
    The h file contains

    class C_GL_Strip_Chart : public QGLWidget
    { …
    public slots:
       void interval_timer( void );
    private:
       QTimer   *m_timer;
     … }
    

    The cpp file contains

    C_GL_Strip_Chart::C_GL_Strip_Chart(  QGLWidget * parent )
       : QGLWidget( parent, “qglwidget”, 0, Qt::WStyle_DialogBorder)
    { …  // That QGLWidget may be significant
    interval_timer();  // this call is sucessful
    m_timer = new QTimer( this, “strip_chart_timer” ); 
    unsigned short return_value = 999;  // gets changed to 0.  Different type required here?
    return_value = connect( m_timer, SIGNAL( timeout()), this, SLOT( interval_timer() ) );
    std::cout << “connect done, returned “ << return_value << “\n”;
    … }
    

    Further down is

    void C_GL_Strip_Chart ::interval_timer( void )
    { std::cout << “called\n”; };
    

    It compiles with no errors or warnings. When run the terminal window contains:

    QObject::connect: No such slot QGLWidget::interval_timer()
    QObject::connect:  (sender name: ‘strip_chart_timer’ )
    QObject::connect: (receiver name: ‘qglwidget’ )
    connect done, returned 0
    

    I cannot figure out what is wrong here.

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • B BKBK

      Yes, Qt3, novice programmer. Please try to accommodate typos as I cannot copy paste from my work computer to here. It does run but the connect fails. Found another thread here, same topic, but don’t have the same error as that one.
      The h file contains

      class C_GL_Strip_Chart : public QGLWidget
      { …
      public slots:
         void interval_timer( void );
      private:
         QTimer   *m_timer;
       … }
      

      The cpp file contains

      C_GL_Strip_Chart::C_GL_Strip_Chart(  QGLWidget * parent )
         : QGLWidget( parent, “qglwidget”, 0, Qt::WStyle_DialogBorder)
      { …  // That QGLWidget may be significant
      interval_timer();  // this call is sucessful
      m_timer = new QTimer( this, “strip_chart_timer” ); 
      unsigned short return_value = 999;  // gets changed to 0.  Different type required here?
      return_value = connect( m_timer, SIGNAL( timeout()), this, SLOT( interval_timer() ) );
      std::cout << “connect done, returned “ << return_value << “\n”;
      … }
      

      Further down is

      void C_GL_Strip_Chart ::interval_timer( void )
      { std::cout << “called\n”; };
      

      It compiles with no errors or warnings. When run the terminal window contains:

      QObject::connect: No such slot QGLWidget::interval_timer()
      QObject::connect:  (sender name: ‘strip_chart_timer’ )
      QObject::connect: (receiver name: ‘qglwidget’ )
      connect done, returned 0
      

      I cannot figure out what is wrong here.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @BKBK said in QTimer will not connect:

      Do you have Q_OBJECT macros right at the beginning of C_GL_Strip_Chart body?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      2
      • B BKBK

        Yes, Qt3, novice programmer. Please try to accommodate typos as I cannot copy paste from my work computer to here. It does run but the connect fails. Found another thread here, same topic, but don’t have the same error as that one.
        The h file contains

        class C_GL_Strip_Chart : public QGLWidget
        { …
        public slots:
           void interval_timer( void );
        private:
           QTimer   *m_timer;
         … }
        

        The cpp file contains

        C_GL_Strip_Chart::C_GL_Strip_Chart(  QGLWidget * parent )
           : QGLWidget( parent, “qglwidget”, 0, Qt::WStyle_DialogBorder)
        { …  // That QGLWidget may be significant
        interval_timer();  // this call is sucessful
        m_timer = new QTimer( this, “strip_chart_timer” ); 
        unsigned short return_value = 999;  // gets changed to 0.  Different type required here?
        return_value = connect( m_timer, SIGNAL( timeout()), this, SLOT( interval_timer() ) );
        std::cout << “connect done, returned “ << return_value << “\n”;
        … }
        

        Further down is

        void C_GL_Strip_Chart ::interval_timer( void )
        { std::cout << “called\n”; };
        

        It compiles with no errors or warnings. When run the terminal window contains:

        QObject::connect: No such slot QGLWidget::interval_timer()
        QObject::connect:  (sender name: ‘strip_chart_timer’ )
        QObject::connect: (receiver name: ‘qglwidget’ )
        connect done, returned 0
        

        I cannot figure out what is wrong here.

        J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @BKBK said in QTimer will not connect:

        return_value = connect( m_timer, SIGNAL( timeout()), this, SLOT( interval_timer() ) );

        this is one of the reasons I personally prefere the new (Qt5) SignalSlot syntax, compile time check of the connects ;-)

        try

        return_value = connect( m_timer, &QTimer::timeout, this, C_GL_Strip_Chart ::interval_timer  );
        

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        2
        • jsulmJ jsulm

          @BKBK said in QTimer will not connect:

          Do you have Q_OBJECT macros right at the beginning of C_GL_Strip_Chart body?

          B Offline
          B Offline
          BKBK
          wrote on last edited by BKBK
          #4

          @jsulm said in QTimer will not connect:

          @BKBK said in QTimer will not connect:

          Do you have Q_OBJECT macros right at the beginning of C_GL_Strip_Chart body?

          Rookie and all, still, I am embarrassed at not thinking of that. Yes, that was my problem.
          And yes, we really do need to upgrade. But,..., the best reasons in the world do not help.
          Thank you
          Edit
          Two lines from the OP

          unsigned short return_value = 999;  // gets changed to 0.  Different type required here?
          return_value = connect( m_timer, SIGNAL( timeout()), this, SLOT( interval_timer() ) );
          

          I saw that return value somewhere but cannot find any documentation about it.
          Is there anything to discover what the return values mean and other functions that may have return values?

          jsulmJ 1 Reply Last reply
          1
          • B BKBK

            @jsulm said in QTimer will not connect:

            @BKBK said in QTimer will not connect:

            Do you have Q_OBJECT macros right at the beginning of C_GL_Strip_Chart body?

            Rookie and all, still, I am embarrassed at not thinking of that. Yes, that was my problem.
            And yes, we really do need to upgrade. But,..., the best reasons in the world do not help.
            Thank you
            Edit
            Two lines from the OP

            unsigned short return_value = 999;  // gets changed to 0.  Different type required here?
            return_value = connect( m_timer, SIGNAL( timeout()), this, SLOT( interval_timer() ) );
            

            I saw that return value somewhere but cannot find any documentation about it.
            Is there anything to discover what the return values mean and other functions that may have return values?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @BKBK Take a look at the documentation: http://doc.qt.io/qt-5/qobject.html#connect

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1

            • Login

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