Qt 5.10.1 如何直接访问 Qt qrc 文件夹
How do I access Qt qrc folder directly Qt 5.10.1
我正在 qml
开发应用程序。
我有一个文件夹 qrc
文件夹结构,如
qrc:
Features
- Media
- Audio
- TV
graphics
- media_assets
- audio_assets
- tv_assets
特征包含相应的 qml
文件,图形包含图形。
我的问题是,从它直接设置为当前的功能加载 qml
文件后,之后当我尝试访问图形文件夹时,我需要返回 ../... / 并访问该文件夹。更改文件夹结构时出现问题。
如何直接从 qrc
访问图形,例如从任何 qml
文件
graphics/media_assets/
在旧版本中,我可以使用 "file://sample.png"
直接访问图形,在 qt 5.10.1 中它已被弃用。
使用:
qrc:///
来自 url QML Basic Type 文档:
When referring to files stored with the Qt Resource System from within
QML, you should use "qrc:///" instead of ":/" as QML requires URL
paths. Relative URLs resolved from within that file will use the same
protocol.
我正在 qml
开发应用程序。
我有一个文件夹 qrc
文件夹结构,如
qrc:
Features
- Media
- Audio
- TV
graphics
- media_assets
- audio_assets
- tv_assets
特征包含相应的 qml
文件,图形包含图形。
我的问题是,从它直接设置为当前的功能加载 qml
文件后,之后当我尝试访问图形文件夹时,我需要返回 ../... / 并访问该文件夹。更改文件夹结构时出现问题。
如何直接从 qrc
访问图形,例如从任何 qml
文件
在旧版本中,我可以使用 "file://sample.png"
直接访问图形,在 qt 5.10.1 中它已被弃用。
使用:
qrc:///
来自 url QML Basic Type 文档:
When referring to files stored with the Qt Resource System from within QML, you should use "qrc:///" instead of ":/" as QML requires URL paths. Relative URLs resolved from within that file will use the same protocol.