Search code examples
visual-studioqtvisual-c++qobject

Q_OBJECT Problem in Visual C++


I have received a Visual C++ QT based project from our customer. I have installed QT libraries then I have compiled the project. The Project was compiled without any problems.

Now, I need to include a new additional GUI interface with the existing project. I have created a GUI in QT designer then saved in the source directory of VC++ project. Then I have written .h and .cpp file for new GUI and could call this interface. Now I need to include SIGNALS and SLOTS, when I include Q_OBJECT in .h file. I have compilation error.

These are the errors, please help me to solve this problem:

unresolved external symbol "public: virtual struct QMetaObject const * __thiscall BetaLineServer::metaObject(void)const " (?metaObject)

unresolved external symbol "public: virtual void * __thiscall BetaLineServer::qt_metacast(char const *)"

unresolved external symbol "public: virtual int __thiscall BetaLineServer::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@

Solution

  • You probably just need to add your .ui, .cpp and .h files to the project file.

    Qt will run 'moc' on the ui file if it's listed there, which creates source code to supply your missing symbols.