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. Unresolved Externals In Parent After Deleting Child Class

Unresolved Externals In Parent After Deleting Child Class

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 470 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.
  • A Offline
    A Offline
    Andaharoo
    wrote on last edited by
    #1

    I've created this simple class called DragButton which simply intercepts the mouse move event and updates the position of the button. It then gives out a new signal called mousemove that returns a pointer to the button itself for more control. I might change this later.

    #pragma once
    
    #include <QPushButton>
    
    class DragButton : public QPushButton
    {
        Q_OBJECT
    public:
        DragButton(QWidget *parent);
        void emitMouseMove() { mouseMove(this); }
        ~DragButton();
    
    signals:
        void mouseMove(QPushButton* button);
        
    protected:
        void mouseMoveEvent(QMouseEvent* event) override;
    };
    

    This solution works for a time. But after I created another button called NodeButton that would inherit this button with some more information to go along with the DragButton I ran into some errors and deleted the NodeButton class. And now the DragButton throws a bunch of unresolved externals:

    1>DragButton.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl DragButton::metaObject(void)const " (?metaObject@DragButton@@UEBAPEBUQMetaObject@@XZ)
    1>DragButton.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl DragButton::qt_metacast(char const *)" (?qt_metacast@DragButton@@UEAAPEAXPEBD@Z)
    1>DragButton.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl DragButton::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@DragButton@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
    1>DragButton.obj : error LNK2019: unresolved external symbol "public: void __cdecl DragButton::mouseMove(class QPushButton *)" (?mouseMove@DragButton@@QEAAXPEAVQPushButton@@@Z) referenced in function "public: void __cdecl DragButton::emitMouseMove(void)" (?emitMouseMove@DragButton@@QEAAXXZ)
    

    I also got these unresolved externals earlier somehow and the only way for me to fix it was to remake the class? Is there anyway to fix this without remaking the class? Is there some extra step I need to take when deleting QT classes in vs. I've tried rebuilding, cleaning, manually deleting all the generated files. Nothing fixes it except remaking the class.
    Note: I'm using the Qt extension in visual studios.

    kshegunovK 1 Reply Last reply
    0
    • A Andaharoo

      I've created this simple class called DragButton which simply intercepts the mouse move event and updates the position of the button. It then gives out a new signal called mousemove that returns a pointer to the button itself for more control. I might change this later.

      #pragma once
      
      #include <QPushButton>
      
      class DragButton : public QPushButton
      {
          Q_OBJECT
      public:
          DragButton(QWidget *parent);
          void emitMouseMove() { mouseMove(this); }
          ~DragButton();
      
      signals:
          void mouseMove(QPushButton* button);
          
      protected:
          void mouseMoveEvent(QMouseEvent* event) override;
      };
      

      This solution works for a time. But after I created another button called NodeButton that would inherit this button with some more information to go along with the DragButton I ran into some errors and deleted the NodeButton class. And now the DragButton throws a bunch of unresolved externals:

      1>DragButton.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl DragButton::metaObject(void)const " (?metaObject@DragButton@@UEBAPEBUQMetaObject@@XZ)
      1>DragButton.obj : error LNK2001: unresolved external symbol "public: virtual void * __cdecl DragButton::qt_metacast(char const *)" (?qt_metacast@DragButton@@UEAAPEAXPEBD@Z)
      1>DragButton.obj : error LNK2001: unresolved external symbol "public: virtual int __cdecl DragButton::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@DragButton@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)
      1>DragButton.obj : error LNK2019: unresolved external symbol "public: void __cdecl DragButton::mouseMove(class QPushButton *)" (?mouseMove@DragButton@@QEAAXPEAVQPushButton@@@Z) referenced in function "public: void __cdecl DragButton::emitMouseMove(void)" (?emitMouseMove@DragButton@@QEAAXXZ)
      

      I also got these unresolved externals earlier somehow and the only way for me to fix it was to remake the class? Is there anyway to fix this without remaking the class? Is there some extra step I need to take when deleting QT classes in vs. I've tried rebuilding, cleaning, manually deleting all the generated files. Nothing fixes it except remaking the class.
      Note: I'm using the Qt extension in visual studios.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      Is this in a library? If so you must export your classes (see here).
      If this is not a library, then there's something wrong with the moc - the generated file isn't linked for some reason. Try rerunning qmake and making a full rebuild.

      Read and abide by the 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