添加Qt Widgets Designer 插件

您可以创建插件,在Qt Widgets Designer 中添加自己的部件。要在应用程序中包含插件,可将其编译为一个动态库,单独发布,应用程序可在运行时检测并加载该动态库。

应用程序可以检测标准插件子目录中的插件。有关如何创建和定位插件以及更改默认插件路径的更多信息,请参阅如何创建 Qt 插件

有关如何为Qt Widgets Designer 创建插件的更多信息,请参阅使用Qt Widgets Designer 自定义部件

查找Qt Widgets Designer 插件

Qt Widgets Designer 会从标准位置获取插件,并加载与其构建密钥相匹配的插件。 Designer 既可以作为独立应用程序提供,也可以集成到 中。放置插件的正确文件夹取决于您使用的是独立的 Designer 还是集成的 Designer。Qt Widgets Qt Creator Qt Widgets Qt Widgets

集成的Qt Widgets Designer 从Qt Creator 安装目录中获取插件。Designer 插件在 Windows 上从<QtCreator>\bin\plugins\designer 加载,在 Linux 上从<QtCreator>/lib/Qt/plugins/designer 加载,在 macOS 上从 加载。 Qt Creator.app/Contents/PlugIns/designer在 macOS 上。

要检查哪些插件加载成功,哪些失败,请选择Tools >Form Editor > 。 About Qt Widgets Designer Plugins.

独立的Qt Widgets Designer 是用于构建项目的 Qt 库的一部分,位于 Qt 安装目录中的<Qt_version>\<compiler>\bin 。它从bin\plugins\designer 子目录中获取插件。要检查哪些插件加载成功,哪些失败,请在 Linux 和 Windows 上选择Help >About Plugins (或在 MacOS 上选择 Qt Creator>About Plugins )。

匹配构建密钥

Windows 上预置 Qt 软件包中包含的Qt Creator 是使用 Microsoft Visual Studio 编译器构建的。如果您安装了使用 MinGW/g++ 编译器构建的 Qt 版本,Qt Creator 就无法加载使用 Windows 版本构建的插件,因为构建密钥不匹配。

如果使用的 Qt 版本比Qt Creator 所使用的 Qt 版本更新,或在其他方面不兼容,情况也是如此。这样,插件就只能在Qt Widgets Designer 的独立版本中使用。选择Help > About Qt Creator来检查Qt Creator 的 Qt 版本和编译器。

要使用为出厂 Qt 版本构建的Qt Widgets Designer 插件,请确保Qt Creator 是使用相同的编译器构建的,具体方法是使用 MinGW 重新编译Qt Creator 或安装使用 Microsoft Visual Studio 构建的 Qt 版本,这取决于您想在应用程序中使用哪种配置。

另请参阅 教程:Qt Widgets 应用程序Qt Widgets Designer

Copyright © The Qt Company Ltd. and other contributors. 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.