相关疑难解决方法(0)

未解析的外部符号"public:virtual struct QMetaObject const*__thiscall Parent

我从QObject继承了一个类:

class Parent: public QObject
{
    Q_OBJECT
    QObject* cl;

public:
    Parent(QObject *parent=0):QObject(parent) {
        cl = NULL;
    }

    QObject* getCl() const {
        return cl;
    }
    void setCl(QObject *obj) {
        cl = obj;
    }
};
Run Code Online (Sandbox Code Playgroud)

但是当我写道:

Parent ev;
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Parent::metaObject(void)const " (?metaObject@Parent@@UBEPBUQMetaObject@@XZ)

main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __thiscall Parent::qt_metacast(char const *)" (?qt_metacast@Parent@@UAEPAXPBD@Z)

main.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __thiscall Parent::qt_metacall(enum QMetaObject::Call,int,void …
Run Code Online (Sandbox Code Playgroud)

c++ qt qobject

67
推荐指数
8
解决办法
7万
查看次数

标签 统计

c++ ×1

qobject ×1

qt ×1