qt_wrap_ui
为 .ui 文件创建源代码。
该命令在Qt6
软件包的Widgets
组件中定义。用以下命令加载软件包
find_package(Qt6 REQUIRED COMPONENTS Widgets)
简介
qt_wrap_ui(<VAR> ui_file1 [ui_file2 ...] [OPTIONS ...])
如果禁用了无版本命令,请使用qt6_wrap_ui()
代替。它支持与该命令相同的参数集。
说明
在给定的.ui
文件上创建调用User Interface Compiler (uic)的规则。对于每个输入文件,都会在构建目录中生成一个头文件。生成的头文件路径会添加到<VAR>
中。
注意: 这是一个低级宏。有关使用uic
处理.ui
文件的更便捷方法,请参阅CMake AUTOUIC 文档。
自 6.8:
注意: qt_add_ui是处理.ui
文件的推荐方法。
选项
您可以设置应添加到uic
调用中的其他OPTIONS
。您可以在uic 文档中找到可能的选项。
示例
set(SOURCES mainwindow.cpp main.cpp) qt_wrap_ui(SOURCES mainwindow.ui) qt_add_executable(myapp ${SOURCES})
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.