C
ImageFiles.MCU.prefix
为图像资源的URI添加一个通用前缀。
描述
prefix 节点会在用于访问资源的URI前添加一个通用前缀。
用法
该属性可在主应用程序的 `.qmlproject ` 文件或模块的 `.qmlproject ` 文件中使用。它接受字符串参数。
代码示例:
# In myproject.qmlproject file
ImageFiles {
// Specify the prefix for images declared within the current node
MCU.prefix: "assets"
files: ["map/small.png"]
}
# In CustomItem.qml
Image {
id: image
source: "/assets/map/small.png"
}base 属性可与prefix 属性结合使用。
注意: 即使未找到base ,prefix 仍会添加到 URI 中。
# In myproject.qmlproject file
ImageFiles {
// Specify the prefix for images declared within the current node
MCU.base: "photos"
MCU.prefix: "pictures"
files: ["photos/hires/house.png", "map/small.png"]
}
Image {
id: image1
source: "/pictures/hires/house.png"
}
Image {
id: image2
source: "/pictures/map/small.png"
}由于
该属性是在 QmlProject API 1.3 中引入的。
在某些 Qt 许可证下可用。
了解更多信息。