QTP0001
':/qt/qml/' 是 Qml 模块的默认资源前缀。
该策略自 Qt 6.5 起引入。它更改了qt_add_qml_module()在资源系统中存储 QML 资源的位置。
启用此策略可确保您的 QML 模块被放置在默认导入路径下,且无需手动调用QQmlEngine::addImportPath 即可找到其类型。
该策略的 `OLD ` 行为是:qt_add_qml_module() 的 `RESOURCE_PREFIX ` 参数默认值为 `"/"`。
该策略在NEW 中的行为是:qt_add_qml_module() 的RESOURCE_PREFIX 参数默认值为"/qt/qml/" 。这种新行为确保模块会被放入QML 导入路径,无需额外配置即可被找到。
如果您未向qt_add_qml_module 命令传递以下任何参数:RESOURCE_PREFIX 、NO_RESOURCE_TARGET_PATH ,Qt 6.5 会发出警告。请使用qt_policy()命令,通过将策略显式设置为OLD 或NEW 来抑制该警告。
注意: 策略的“OLD ”行为 已弃用,未来可能会被移除。
另请参阅 qt_policy()、qt_standard_project_setup()、qt_cmake_policies 和qt_add_qml_module()。
© 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.