未解析的外部符号“public: virtual struct QMetaObject const * __thisca

Unresolved external symbol quot;public: virtual struct QMetaObject const * __thiscall Parent(未解析的外部符号“public: virtual struct QMetaObject const * __thiscall Parent)
本文介绍了未解析的外部符号“public: virtual struct QMetaObject const * __thiscall Parent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我从 QObject 继承了一个类:

I inherited a class from 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;
    }
};

但是当我写:

Parent ev;

我收到以下错误:

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 * *)" (?qt_metacall@Parent@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

推荐答案

您应该删除应用程序的 debug 文件夹,然后再次运行以解决此问题.

You should delete the debug folder of your application and run it again to correct this problem.

这篇关于未解析的外部符号“public: virtual struct QMetaObject const * __thiscall Parent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

QVector vs QList(QVector 与 QList)
How to create/read/write JSON files in Qt5(如何在 Qt5 中创建/读取/写入 JSON 文件)
Qt: How do I handle the event of the user pressing the #39;X#39; (close) button?(Qt:如何处理用户按下“X(关闭)按钮的事件?)
STL or Qt containers?(STL 还是 Qt 容器?)
Sort filenames naturally with Qt(使用 Qt 自然地对文件名进行排序)
Qt macro keywords cause name collisions(Qt 宏关键字导致名称冲突)