Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Undefined reference to 'vtable to FocusWatcher'



  • I found this script on the internet but when I try to build it i got this error: "Undefined reference to 'vtable to FocusWatcher' ".

    #include<QEvent>
    #include<QObject>
    
    class FocusWatcher : public QObject
    {
       Q_OBJECT
    public:
       explicit FocusWatcher(QObject* parent = nullptr) : QObject(parent)
       {
          if (parent)
             parent->installEventFilter(this);
       }
       virtual bool eventFilter(QObject *obj, QEvent *event) override
       {
          Q_UNUSED(obj)
          if (event->type() == QEvent::FocusIn)
             emit focusChanged(true);
          else if (event->type() == QEvent::FocusOut)
             emit focusChanged(false);
          return false;
       }
    
       virtual ~FocusWatcher() {}
    
    Q_SIGNALS:
       void focusChanged(bool in);
    };
    

  • Lifetime Qt Champion

    Hi,

    How are you compiling it ?


Log in to reply