Visual C++ 中的 Q_OBJECT 问题 [英] Q_OBJECT Problem in Visual C++

查看:34
本文介绍了Visual C++ 中的 Q_OBJECT 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从我们的客户那里收到了一个基于 Visual C++ QT 的项目.我已经安装了 QT 库,然后我编译了项目.项目编译没有任何问题.

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.

现在,我需要在现有项目中包含一个新的附加 GUI 界面.我在 QT 设计器中创建了一个 GUI,然后保存在 VC++ 项目的源目录中.然后我为新的 GUI 编写了 .h 和 .cpp 文件,并且可以调用这个接口.现在,当我在 .h 文件中包含 Q_OBJECT 时,我需要包含 SIGNALS 和 SLOTS.我有编译错误.

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.

这些是错误,请帮我解决这个问题:

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@

推荐答案

您可能只需要将 .ui、.cpp 和 .h 文件添加到项目文件中.

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

Qt 将在 ui 文件上运行moc"(如果它在那里列出),它会创建源代码来提供您缺少的符号.

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

这篇关于Visual C++ 中的 Q_OBJECT 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆