Unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Parent

后端 未结 23 2363
醉话见心
醉话见心 2020-11-30 21:33

I inherited a class from QObject :

class Parent: public QObject
{
    Q_OBJECT
    QObject* cl;

public:
    Parent(QObject *parent=0):QObject(parent) {
            


        
23条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-30 22:17

    I noticed some answers are based on Visual Studio.

    This answer is based on Qt Creator.

    Unlike the name suggest, Rebuild Project will not wipe out everything and build from scratch. If you recently added QObject (and/or Q_OBJECT) to your class, you'll have to run qmake again, e.g.

    1. Clean Project
    2. Run qmake
    3. Build Project

    This is because, by default, qmake only runs when you do significant changes to your solution like adding new source files or modify the .pro file. If you make edits to an existing file, it doesn't know it needs to run qmake.

    As a fall back, to brute force Qt to build everything from scratch, delete the Debug or Release folder.

提交回复
热议问题