Details
-
Suggestion
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.0.1
-
None
Description
Regular image loading takes advantage of automatic resolution of paths. For example, if I have the following QML file:
Image {
source: "../images/myimage.png"
}
the path to myimage.png will be resolved relative to MyFile.qml. This is quite useful, especially when using resource files.
When using image providers, there is no automatic resolution. For example, if the source were changed to "image://myprovider/../images/myimage.png", myprovider would receive the path "../images/myimage.png", but no indication of how it should be resolved. This may not be an issue for many image providers, as they provide specialized loading, and aren't necessarily using a file path.
However, particularly in the case of textures, texture providers are currently the preferred way to support a new format (rather than image format plugins), which means they cannot easily take advantage of automatic resolution relative to QML file.
Possible alternatives:
- All paths are resolved by the texture provider, relative to the binary.
- A texture provider could have e.g. a setBaseUrl() function, which is used to resolve all paths.
- The following workaround could be used, though it becomes tedious if the entire application uses a texture provider:
Image { property url resolvedSource: "../images/myimage.png" source: "image://myprovider/" + resolvedSource }
- The engine automatically resolves the last half of "image://myprovider/../images/myimage.png". This is problematic, as some providers may want to use relative paths, while others may want to use ids, which shouldn't be resolved as paths. Perhaps a special indication could be inserted to indicate the use of a path? e.g. always require a . or .. directly after "image://myprovider/", or provide a 'port', e.g.: "image://myprovider:relative/".
I think (4) offers the nicest solution if it can be made to work.
Attachments
Issue Links
- relates to
-
QTBUG-37279 QQuickImageProvider does not always preserve id
- Reported
Gerrit Reviews
For Gerrit Dashboard: QTBUG-29451 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
193642,10 | Add very basic compressed texture support | dev | qt/qtdeclarative | Status: MERGED | -2 | 0 |