我是Qt的新手,现在我正在使用Visual Studio 2008开发一个简单的应用程序,在构建代码时,会出现以下错误:
error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Window::metaObject(void)const " (?metaObject@Window@@UBEPBUQMetaObject@@XZ)
error LNK2001: unresolved external symbol "public: virtual void * __thiscall Window::qt_metacast(char const *)" (?qt_metacast@Window@@UAEPAXPBD@Z)
error LNK2001: unresolved external symbol "public: virtual int __thiscall Window::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Window@@UAEHW4Call@QMetaObject@@HPAPAX@Z)
error LNK2001: unresolved external symbol "public: static struct QMetaObject const Window::staticMetaObject" (?staticMetaObject@Window@@2UQMetaObject@@B)
fatal error LNK1120: 4 unresolved externals
如何解决这些错误?
答案 0 :(得分:0)
您需要在使用Q_OBJECT宏或从QObject继承的头文件上运行moc.exe。 为简单起见,只需安装此qt vs addin即可为您添加所有内容。您可能需要生成一个新项目。