c++ - 在带有 VS 2008 的 Qt 4.8.5 网络示例中找不到 ui_chatdialog.h

标签 c++ qt visual-studio-2008 visual-studio-2012

我刚开始使用 Qt 进行开发,我希望编译 Qt 4.8.5 附带的 Qt 网络聊天示例:http://qt-project.org/doc/qt-4.8/network-network-chat.html

我在 VS 2012 中工作,但使用 VS 2008 进行编译。我有以下内容:

C:\Qt\4.8.5\include\Qt;
C:\Qt\4.8.5\include\QtUiTools;
C:\Qt\4.8.5\include;
C:\Qt\4.8.5\include\QtCore;
C:\Qt\4.8.5\include\QtGui;
C:\Qt\4.8.5\include\QtNetwork;
%(AdditionalIncludeDirectories)

我觉得我在编译过程中遗漏了一些步骤,也许是生成 ui_chatdialog.h 文件的步骤?我无法弄清楚为什么示例中缺少它,并且它不存在于我下载的 Qt 版本 (4.8.5) 附带的文件中。

这是我当前的输出:

>------ Rebuild All started: Project: QTChatExample, Configuration: Release Win32 ------
1>  chatdialog.cpp
1>c:\users\dustin\documents\qtchatexample\src\chatdialog.h(44): fatal error C1083: Cannot open include file: 'ui_chatdialog.h': No such file or directory
1>  client.cpp
1>  connection.cpp
1>  main.cpp
1>c:\users\dustin\documents\qtchatexample\src\chatdialog.h(44): fatal error C1083: Cannot open include file: 'ui_chatdialog.h': No such file or directory
1>  peermanager.cpp
1>  server.cpp
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

最佳答案

您需要运行 uic 来为您的 ui 文件生成头文件

http://qt-project.org/doc/qt-4.8/uic.html

而且您还需要 moc 来为信号和槽之类的东西生成源元对象代码。

http://qt-project.org/doc/qt-4.8/metaobjects.html

执行此操作的一种方法是使用适用于 Visual Studio 的 Qt 插件。尽管您可以创建一个自定义构建步骤来执行 moc、uic 和资源编译器,或者使用 QMake 或 CMake,它们也会为您执行这些。

http://qt-project.org/faq/answer/what_is_the_qt_visual_studio_add-in

因为你也为 VS2012 标记了这个问题,我将添加以下内容:

Is it possible to work with Qt4 projects in Visual Studio 2012 using add-ins?

关于c++ - 在带有 VS 2008 的 Qt 4.8.5 网络示例中找不到 ui_chatdialog.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18497327/

相关文章:

c++ - 错误 C2059 : syntax error : '<end Parse>'

c++ - 将非类型参数包分布在不同的模板参数包中

c++ - 大量关键部分有任何问题吗?

c++ - 访问 C 中结构数组中的数组(结构成员)

c++ - 诺基亚 lumia 1020 USB 大容量存储访问 C++

c++ - keypressevent()中的qt多个键

qt - 当父级调整大小时如何更改位置?

visual-studio - 在 Visual Studio 中使用 Qt 设计器?

c++ - 即使在设计器中更改高度后,组合框下拉菜单也不起作用

visual-studio-2008 - 添加成员变量向导中的控制变量被禁用。为什么?