QT_QML_SINGLETON_TYPE

用于标记一个 QML 文件提供单例类型。

该属性于 Qt 6.2 中引入。

提供单例类型的.qml 文件需要将其QT_QML_SINGLETON_TYPE 源属性设置为TRUE ,以确保将单例命令写入qmldir文件。除了在QML文件中包含pragma Singleton 语句外,还必须执行此操作。源属性必须在创建单例所属的模块之前进行设置。

有关如何设置QT_QML_SINGLETON_TYPE 属性的示例,请参阅qt_target_qml_sources()。

另请参阅 qt_target_qml_sources。

© 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.