From 60d99b6413600194a2d1f3dde8313b55bf3d12f0 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Wed, 13 Dec 2017 23:23:42 +0000 Subject: [PATCH] Rework the "failed to find or load QPA plugin" message a bit This is one of the most frequent problems users ask for help with, and they don't even know if the plugin was found but not loaded or simply not found. Qt knows what happened, so communicate it to the user. Change-Id: I6003ed4ab3d147a5d159b2002004e53c251cb512 Reviewed-by: Jake Petroules Reviewed-by: Friedemann Kleint Reviewed-by: David Faure Reviewed-by: Thiago Macieira --- src/gui/kernel/qguiapplication.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index f566677ff4..37fbfe679d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1140,8 +1140,14 @@ static void init_platform(const QString &pluginArgument, const QString &platform if (Q_UNLIKELY(!QGuiApplicationPrivate::platform_integration)) { QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); - QString fatalMessage - = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\"\nin \"%2\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath)); + QString fatalMessage; + if (keys.contains(name)) { + fatalMessage = QStringLiteral("This application failed to start because it could not load the Qt platform plugin \"%2\"\nin \"%3\", even though it was found. ").arg(name, QDir::toNativeSeparators(platformPluginPath)); + fatalMessage += QStringLiteral("This is usually due to missing dependencies, which you can verify by setting the env variable QT_DEBUG_PLUGINS to 1.\n\n"); + } else { + fatalMessage = QStringLiteral("This application failed to start because it could not find the Qt platform plugin \"%2\"\nin \"%3\".\n\n").arg(name, QDir::toNativeSeparators(platformPluginPath)); + } + if (!keys.isEmpty()) { fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg( keys.join(QLatin1String(", ")));