VS2022+QT5.13.2:无法打开 源 文件 “ui_QtGuiApplicationx.h“在解决方案(亲测有效)

@[TOC]问题描述
VS2022+QT5.13.2 在工程文件,生成解决方案在时候提示如下错误:
错误(活动) E1696 无法打开 源 文件 “ui_QtWidgetsApplication1.h” QtWidgetsApplication1 E:\test\QtWidgetsApplication1\QtWidgetsApplication1.h 4

错误 C1083 无法打开包括文件: “ui_QtWidgetsApplication1.h”: No such file or directory (编译源文件 QtWidgetsApplication1.cpp) QtWidgetsApplication1 E:\test\QtWidgetsApplication1\QtWidgetsApplication1.h 4

如图所示:
在这里插入图片描述
其表象原因在于ui_QtGuiApplicationx.h不存在。熟悉QT在都知道,这种ui开头的头文件通常都是IDE自动生产的,因此可以初步判断,VS没有自动生成该文件。

@[TOC]解决方案:
1、右键点击对应的ui文件,然后选择属性
在这里插入图片描述
2、在弹出的对话框中,将常规选项卡下的“项类型”改为QT User Interface Compiler(uic)。
然后点击应用,确定。
在这里插入图片描述
3、然后重新编译运行即可。在项目文件下的 x64\Debug\uic文件中就有对应的ui头文件生成了。
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/ge2ming/article/details/129547420