自定义Qt Widgets Designer 表单

在Qt Widgets Designer 中保存表单时,它将作为UI文件存储。 一些表单设置(例如网格设置或默认布局的边距和间距)会与表单的组件一同存储。当uic生成表单的 C++ 代码时,会使用这些设置。有关如何在应用程序中使用表单的更多信息,请参阅“在 C++ 应用程序中使用Qt Widgets Designer UI 文件”一节。
修改表单设置
要修改表单设置,请打开“表单”菜单并选择“表单设置...”
在表单设置对话框中,您可以指定表单的作者。
您还可以修改表单默认布局(Layout Default)的边距和间距属性。当uic 为表单生成代码时,如果指定了相应的布局函数,这些默认布局属性将被该函数替换。表单设置对话框允许您为边距和间距分别指定函数。
![]() | 布局函数 当 要为表单的边距和间距指定布局函数,请选中“布局函数”组框以启用相应输入框。 |
您还可以为表单指定“包含提示”(Include Hints);即提供一组头文件列表,这些头文件随后将被包含到表单窗口的相关 UI 文件中。 头文件可以是本地文件(即相对于项目目录"mywidget.h" ),也可以是全局文件(即 Qt 或编译器标准库的一部分:<QtWidgets/QWidget> )。
最后,您可以指定用于将位图加载到表单窗口中的函数(即“位图函数”)。
© 2026 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.
