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
命令传递以下任何参数,Qt 6.5 会发出警告:RESOURCE_PREFIX
,NO_RESOURCE_TARGET_PATH
。使用qt_policy命令,通过明确设置策略为OLD
或NEW
来抑制警告。
注意: 策略的OLD
行为已被弃用,将来可能会被移除。
另请参阅 qt_policy、qt_standard_project_setup()、qt_cmake_policies 和qt_add_qml_module。
© 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.