报错问题如下
cpp
AutoUic error
-------------
"SRC:/confirmwizardpage.cpp"
includes the uic file "ui_confirmwizardpage.h",
but the user interface file "confirmwizardpage.ui"
could not be found in the following directories
"SRC:"
ninja: build stopped: subcommand failed.
20:19:41: 进程"E:\Qt\Tools\CMake_64\bin\cmake.exe"退出,退出代码 1 。
Error while building/deploying project alnum (kit: Desktop Qt 6.4.1 MinGW 64-bit)
When executing step "构建"
20:19:41: Elapsed time: 00:00.
出现上面报错问题的原因:是我们原先的ui文件是在主目录下的,为了便于管理,将ui文件移动到一个新的Ui目录中,但此时运行之后,程序就会报错了;
解决办法
在CMakeLists.txt文件中,添加如下代码即可解决问题:
cpp
# 解决ui文件移动到别的文件夹后报错的问题,即指定ui文件路径,这里Ui即为目录
set(CMAKE_AUTOUIC_SEARCH_PATHS "Ui")