2014-04-18 102 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插件。