2014-04-18 107 views
1

我想为我的Qt页面实现多级继承。Qt中的多级继承

class MyPage1: public QWizardPage { 

Q_OBJECT 

... 

} 

and 

class MyPage2: public MyPage1 { 
Q_OBJECT 

... 

} 

的moc_MyPage2.cc是空的,而连接我得到一个错误:

error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall dsw::MyPage2::metaObject(void)const " ([email protected]@[email protected]@[email protected]@XZ)

是否有人可以指导我?如果没有正确生成的moc文件预计

+3

我将文件MyPage2重命名为MyPage21,并重新启动了Visual Studio,清理并构建了该项目,并且工作正常! – PDH

+0

是啊!即使我在与Visual Studio一起使用Qt时也遇到过链接问题 – DNamto

回答

1

The moc_MyPage2.cc is empty and while linking I am getting an error,

error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall dsw::MyPage2::metaObject(void)const " ([email protected]@[email protected]@[email protected]@XZ)

链接器错误,所以真正的问题是,为什么没有正确生成的moc文件。

干净的版本应该可以解决这个问题。如果再次出现连接器错误,检查是否生成了moc文件。另外,我假设你正在为Visual Studio使用Qt Add-In插件。