1
votes

I am trying to implement multilevel inheritance for my Qt pages.

class MyPage1: public QWizardPage {

Q_OBJECT

...

}

and 

class MyPage2: public MyPage1 {
Q_OBJECT

...

}

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 " (?metaObject@MyPage2@dsw@@UBEPBUQMetaObject@@XZ)

Can someone please guide me?

1
I renamed the file MyPage2 to MyPage21 and restarted visual studio, cleaned and built the project and it worked!PDH
Yeah! even I faced linking issues while working with Qt on visual studioDNamto

1 Answers

1
votes

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 " (?metaObject@MyPage2@dsw@@UBEPBUQMetaObject@@XZ)

The linker error is expected if the moc file is not generated properly, so the real question is why the moc file was not generated properly.

A clean build should resolve this. Check then if the moc file is generated if you got the linker error again. Also, I assume you are using the Qt Add-In plugin for Visual Studio.