diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-09-09 16:34:59 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-10 14:29:41 +0000 |
commit | 94f613155cf9f705731c6511ee85395a24d76a25 (patch) | |
tree | 3d070eef521f7603a0b70070747b8ad1baf8e3cd /src | |
parent | b67cb7df1d58800aac893dae1dd126dd348affd8 (diff) |
Document chnaged behavior of url properties
Task-number: QTBUG-95587
Change-Id: I5f465bd37673d3a2e592def50550aacef9e060cd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit bd1a62be001523602abaebfd6afb45ae15cfa871)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc | 30 |
1 files changed, 5 insertions, 25 deletions
diff --git a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc index 5716f6c386..6cb0227502 100644 --- a/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc +++ b/src/qml/doc/src/qmllanguageref/typesystem/basictypes.qdoc @@ -267,31 +267,11 @@ property is only invoked when the property is reassigned to a different object v var urlObject = new URL(url); \endqml - \section1 Using the url Type - - When a relative URL is written to a \c url type property, it is converted - into a URL object, so \b {matching the URL value against the input string - value will fail}. Instead, convert the string to a URL using Qt.resolvedUrl() - for means of comparison, and use \c toString() to get the contents of the URL: - - \qml - Image { - source: "pics/logo.png" - - Component.onCompleted: { - // This prints 'false'. Although "pics/logo.png" was the input string, - // it's been converted from a string to a URL, so these two are not the same. - console.log(source == "pics/logo.png") - - // This prints 'true' as Qt.resovledUrl() converts the string into a - // URL with the correctly resolved path - console.log(source == Qt.resolvedUrl("pics/logo.png")) - - // This prints the absolute path, e.g. "file:///path/to/pics/logo.png" - console.log(source.toString()) - } - } - \endqml + \note In Qt 5, URLs were automatically resolved based on the current context + when assigning them to any \c url property. This made it impossible to + work with relative URLs and it created inconsistent behavior when reading + back a URL previously written to a property. Therefore, the behavior was + changed in Qt 6. \note When referring to files stored with the \l{resources.html}{Qt Resource System} from within QML, you should use "qrc:///" instead of ":/" as QML requires URL paths. |