Commit 2982545d authored by Topi Reinio's avatar Topi Reinio Committed by Christian Kandeler
Browse files

QmlApplicationViewer: properly resolve install paths

This change makes QmlApplicationViewer applications find their qml
resources also in non-installed builds, regardless of the current
working directory.

On non-unix platforms applicationDirPath() is not used at all, and on
unix, it's used only for searching applicationDirPath/../path, which
is valid only after install. In-source or shadow-built apps find
their qml resources only if working directory == application
(executable) directory.

Path may refer to subdirectory in application directory. On windows,
non-installed application binary can also reside in /Release or
/Debug, so its resources need to be searched under parent directory
as well.

Change-Id: I81f602406787c20830c656fd5dffd11aa9b4afba
Reviewed-by: default avatarChristian Kandeler <>
parent 40966bb1
......@@ -56,7 +56,6 @@ class QmlApplicationViewerPrivate
QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
#ifdef Q_OS_UNIX
#ifdef Q_OS_MAC
if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("%1/../Resources/%2")
......@@ -65,11 +64,14 @@ QString QmlApplicationViewerPrivate::adjustPath(const QString &path)
if (!QDir::isAbsolutePath(path))
return QString::fromLatin1("app/native/%1").arg(path);
#elif !defined(Q_OS_ANDROID)
const QString pathInInstallDir =
QString pathInInstallDir =
QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir;
pathInInstallDir =
QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
if (QFileInfo(pathInInstallDir).exists())
return pathInInstallDir;
return path;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment