diff options
| author | Doris Verria <doris.verria@qt.io> | 2026-09-14 13:59:17 +0200 |
|---|---|---|
| committer | Doris Verria <doris.verria@qt.io> | 2026-09-29 09:22:03 +0000 |
| commit | ae03070d2261a5aa81b29a2adf25328472830b4d (patch) | |
| tree | 07acaee1f616e8c7a11d2d2de9463eed528bffce | |
| parent | 1d31dc38583d3017ea3e1c8d40545c7fa81019fc (diff) | |
QStyleKitStyle: Support "qrc:" and "file:" paths
QStyleKitStyle supported only ":" paths in the local file system.
However, adding support for "qrc:" paths as well allows passing the
path to a style file in a compiled QML module, speeding up startup time.
Therefore add support for this schemes to not limit users that want
compiled QML. For symmetry, since we now are supporting qrc: paths,
support "file:" paths too.
Pick-to: 6.12
Change-Id: I0c58c5e09a9c514a6e48a54c7dd65c70b22c79ee
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
| -rw-r--r-- | src/labs/stylekit/widgets/qstylekitstyle.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/labs/stylekit/widgets/qstylekitstyle.cpp b/src/labs/stylekit/widgets/qstylekitstyle.cpp index 7cccff9970..d962417048 100644 --- a/src/labs/stylekit/widgets/qstylekitstyle.cpp +++ b/src/labs/stylekit/widgets/qstylekitstyle.cpp @@ -292,10 +292,9 @@ Q_STATIC_LOGGING_CATEGORY(lcStyleKit, "qt.labs.stylekit") \brief the path to the QML \l Style file driving this style. The value is a path to a local file or to a file in the resource file - system (for example, \c{:/styles/MyStyle.qml}). QStyleKitStyle resolves a - relative path against the application's working directory. The file must - contain a QML component whose root object is a \l Style. - + system, (for example, \c{:/styles/MyStyle.qml} or \c{qrc:/qt/qml/MyQmlModule/Style.qml}). + QStyleKitStyle resolves a relative path against the application's working directory. + The file must contain a QML component whose root object is a \l Style. Setting this property reloads the style. If the new file does not load, QStyleKitStyle emits a warning and keeps the previously loaded style and style path. @@ -577,8 +576,11 @@ QStyleKitStylePrivate::QStyleKitStylePrivate() static QUrl urlFromStylePath(const QString &filePath) { - return filePath.startsWith(QLatin1Char(':')) ? QUrl(QLatin1String("qrc") + filePath) - : QUrl::fromLocalFile(filePath); + if (filePath.startsWith(QLatin1Char(':'))) + return QUrl(QLatin1String("qrc") + filePath); + if (filePath.startsWith(QLatin1String("qrc:")) || filePath.startsWith(QLatin1String("file:"))) + return QUrl(filePath); + return QUrl::fromLocalFile(filePath); } bool QStyleKitStylePrivate::loadStyle() |
