From eb8d0d0c9dfcdb57e8883c738d3e07c5489696b6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 20 Oct 2022 12:11:33 +0200 Subject: Qt Designer: Fix code preview not working in PySide6 on Windows PySide6 installations do not have a proper Qt directory structure on Windows; so, uic is not found via libexec. Use the path of the application instead, which should work in all cases. Fixes error Unable to launch ...\Lib\site-packages\PySide6\bin\uic: Process failed to start: The system cannot find the file specified. Change-Id: I841836a89962f4db962816453b9e99f33ffaf86b Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Jarek Kobus (cherry picked from commit c9b04d4597713a9751b268f30744b4c3cac4ad58) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 7c85c38bb8c392f228f5c3f87cba6b8ba729274d) --- src/designer/src/lib/shared/qdesigner_utils.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/designer/src/lib/shared/qdesigner_utils.cpp b/src/designer/src/lib/shared/qdesigner_utils.cpp index dfd887f91..18668c4a2 100644 --- a/src/designer/src/lib/shared/qdesigner_utils.cpp +++ b/src/designer/src/lib/shared/qdesigner_utils.cpp @@ -13,7 +13,10 @@ #include #include +#include #include +#include +#include #include #include #include @@ -713,7 +716,20 @@ namespace qdesigner_internal { QProcess uic; QStringList arguments; - QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + "/uic"_L1; + static constexpr auto uicBinary = + QOperatingSystemVersion::currentType() != QOperatingSystemVersion::Windows + ? "/uic"_L1 : "/uic.exe"_L1; + QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + uicBinary; + // In a PySide6 installation, there is no libexec directory; uic.exe is + // in the main wheel directory next to designer.exe. + if (!QFileInfo::exists(binary)) + binary = QCoreApplication::applicationDirPath() + uicBinary; + if (!QFileInfo::exists(binary)) { + errorMessage = QApplication::translate("Designer", "%1 does not exist."). + arg(QDir::toNativeSeparators(binary)); + return false; + } + switch (language) { case UicLanguage::Cpp: break; -- cgit v1.2.3