C
图片文件.MCU.前缀
给图片资源 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,也会将前缀添加到 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 许可下可用。
了解更多。