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: no matching member function for call to 'connect'

Error: no matching member function for call to 'connect'

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 479 Views 1 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.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by 8Observer8
    #1

    Hi,

    How to solve the error error: no matching member function for call to 'connect' in the example:

    #include <QApplication>
    #include <QWidget>
    #include <QTimer>
    #include <QDebug>
    
    class Widget : public QWidget
    {
        Q_OBJECT
    public:
        Widget(QWidget *parent = nullptr) : QWidget(parent) {
            connect(m_timer, &QTimer::timeout, this, &Widget::printMessage);
        }
    private slots:
        void printMessage() {
            qDebug() << "timer";
        }
    private:
        QTimer m_timer;
    };
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        Widget w;
        w.show();
        return a.exec();
    }
    
    J.HilkJ 1 Reply Last reply
    0
    • 8Observer88 8Observer8

      Hi,

      How to solve the error error: no matching member function for call to 'connect' in the example:

      #include <QApplication>
      #include <QWidget>
      #include <QTimer>
      #include <QDebug>
      
      class Widget : public QWidget
      {
          Q_OBJECT
      public:
          Widget(QWidget *parent = nullptr) : QWidget(parent) {
              connect(m_timer, &QTimer::timeout, this, &Widget::printMessage);
          }
      private slots:
          void printMessage() {
              qDebug() << "timer";
          }
      private:
          QTimer m_timer;
      };
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          Widget w;
          w.show();
          return a.exec();
      }
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by J.Hilk
      #2

      @8Observer8 your m_timer is on the stack therefore

      connect(&m_timer, &QTimer::timeout, this, &Widget::printMessage);


      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
      3
      • 8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by 8Observer8
        #3

        Thank you very much! But now I have another error in the example above: https://forum.qt.io/topic/117951/error-undefined-reference-to-vtable-for-widget

        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