Qt deploy not working on windows normally - windows

I am using Visual Studio + Qt addon with Qt 5.15.2 x64 and set Run deployment tool to Yes. It seems like this deployment tool is poorly designed and broken. Never understand why Qt cannot make own runtime distibution for Windows like Microsoft did. After deployment when I am trying to open my release exe it just not open. Nothing happens. Yes, I can put it into qt bin folder that weights few gigabytes and it works, but it looks like deploy tool missed some libraries. How to deploy on windows without problems?
(Do not advice me to copy entire Qt bin and remove files one by one and find minimal combination of libraries, I want to make qt deploy automatically)
My errors on app launch:
qrc:/qml/main.qml:3:1: module "QtGraphicalEffects" is not installed
qrc:/qml/main.qml:2:1: module "QtQuick.Window" is not installed
qrc:/qml/main.qml:1:1: module "QtQuick" is not installed
qrc:/qml/main.qml:3:1: module "QtGraphicalEffects" is not installed
qrc:/qml/main.qml:2:1: module "QtQuick.Window" is not installed
qrc:/qml/main.qml:1:1: module "QtQuick" is not installed
qrc:/qml/main.qml:3:1: module "QtGraphicalEffects" is not installed
qrc:/qml/main.qml:2:1: module "QtQuick.Window" is not installed
qrc:/qml/main.qml:1:1: module "QtQuick" is not installed

I found 3rd party Qt deploy toolkit for Windows. It just works fine out of box. I think the only way to solve problems with windeployqt is do not use it and switch to something else.
https://github.com/QuasarApp/CQtDeployer

I usually run windeployqt manually, if it help you:
path\to\windeployqt.exe --release --compiler-runtime path\to\release\build
for example
C:\Qt\5.15.2\msvc2019_64\bin\windeployqt.exe --release --compiler-runtime .\release
Update: if you use QML frontend in your app, as you described in question update, then also specify --qmldir argiment, so that windeployqt could find dependencies not only in compiled .exe import table, but also in non-compiled QML text files. See approved solution https://stackoverflow.com/a/39717117/12691808.

Related

Custom QWidgets. How do I build/get the pyqt5 plugin for Qt Designer on Mac?

I want to be able to create my own custom widgets in Qt Designer using the pyqt5 plugin on my Mac!
On my windows system this is easy. I have/install pyqt5-tools, this contains pyqt5.dll and I copy this into the Qt Designers plugin directory (these packages were all installed via winPython).
I set PYQTDESIGNERPATH=.
In my current directory I have ledplugin.py and ledwidget.py
I start Qt Designer and I have my custom widget to drag and drop
( this tutorial was taken from https://www.ics.com/blog/integrating-python-based-custom-widget-qt-designer )
On my Mac, I can't figure out what the equivalent .dylib of pyqt5.dll is? What is it? Where do I get it? How do I build it?
I try: brew install Qt Creator, that doesn't have the pyqt plugin. I try: brew install pyqt5, that creates: libpyqt5qmlplugin.dylib. I copy that into the Qt Designer plugin dir and the plugin loads, but it doesn't seem to do anything with my .py plugin/widget files.
How do I get this working on a Mac? What is the actual .dylib plugin I'm looking for? I can't find anything googling around.
Thanks for any help
As my comment explained: the Qt designer plugin can be built via the reference link (SIP/PyQt5 via RiverBank and Qt src via Qt).
Make sure your Qt versions match, although Qt docs do say plugins of lower versions should work with Designers on higher versions, but I'm sure there's a limit.
Build inside a python venv, as suggested.
You'll need xtool dev pkg for building.
Everything built really easy for me.
This will place your pyqt5.dylib plugin right in your Qt/clang_64/plugins/designer folder (it will also build it in pyqt5 make folder)
At this point I expected things to work. The plugin shows that it loads fine inside Designer.
Some extra notes:
running from command line can help with debugging: Qt/clang_64/bin/Designer.app > show package > /MacOS/Designer (drag this to a terminal to execute from command line)
set an env variable (>>export QT_DEBUG_PLUGINS=1) will give debug info and show lots of stuff including that pyqt5.dylib loads fine
widget plugins are two files: widget.py and the widgetplugin.py file that exposes the widget to designer. This plugin file MUST end with "plugin.py"
widgetplugin.py files can reside in a number of places:
in /[Designer App]/plugins/designer/python/
in ~/user dir/.designer/plugins/python/
in a directory of you choosing using env var PYQTDESIGNERPATH
However, at this point still nothing showed in Designer and I had no errors to go by. Since I just built pyqt5.dylib, I figured I'd simply put a bunch of print statements in it, re-make it and debug to figure out why the pyqt5 plugin loaded fine, but my custom widgets were nowhere to be found...
first issue was trouble loading a python environment:
for this issue, I simply copied my (I use brew) /usr/local/Cellar/python/3.7.2/Frameworks/Python.framework to Qt/clang_64/lib (I'm sure there's a proper PATH/PYTHONPATH you can set for this, I'll figure that out later)
after that came, missing PyQt5.sip module
for this, I installed (pip install) pyqt5-sip and then put in in my PYTHONPATH
After that, everything finally worked and I could see my custom plugins inside Qt Designer.

Could not find or load qt plugin windows

After having enough in searching and reading peoples questions that had the same problem as i have and trying allot of solutions that doesn't seems to help, I'm posting my question.
I want to run my project- qt application, it ran well when i built it on qt4.8.1 32bit and 5.1.1 64bit. now i want to run it on qt5.3.0 32 bit. i installed qt open source with the following configuration:
qt 5.3.0 msvc2010_opengl 32bit.
Since my projects is using qt solutions- qt single application and qt service, i downloaded the packeges, built it in the new environment and placed them in qt/qt5.3.0/5.3/bin and qt/qt5.3.0/5.3/lib.
(I mention this last detail because a simpler qt project that doesn't use these dlls- service and single application runs well in my environment).
Well, when I run my application from qt it doesn't run. When i run the exe file from the release folder i get the following error:
This application failed to start because it could not find or load the qt platform plugin "windows". reinstalling the application may fix this problem.
I tried all creative ideas:
note: I see that automatically the build arainged the release folder with the folowing struck:
plugin folder with all plugins in it.
platform folder with the hole list of platforms: qwindows.dll, qminimal.dll...
and also put straightly the dlls: qwindows.dll, qwindowsd.dll
libEGL.dll
libEGLd.dll
qt.conf with the data:
[Paths]
Plugins=C:...\build-____-Desktop_Qt_5_3_0_MSVC2010_OpenGL_32bit-Release\release\plugins
I used the dependency walker that told me that the IEShims.dll is missind, so I brought it to the release folder from: C:\Program Files (x86)\Internet Explorer.
Now the dependency walker tells me:
Warning: At least one module has an unresolved import due to a
missing export function in a delay-load dependent module.
I see that the Qt5core.dll->link checksum member in the dependency is marked with red, and also I see it takes it from:
C:\Qt\Qt5.3.0\Tools\QtCreator\bin
so I bring to the release folder the Qt5Core.dll from:
C:\Qt\Qt5.3.0\5.3\msvc2010_opengl\bin. then I get the following message:
the procedure entry point
?bytearrayToDouble#QLocalePrivate##SANPBDPA_N1#Z could not be located
in the dynamic link library
c:/Qt/Qt5.3.0/Tools/QtCreator/bin/Qt5Gui.dll
so maybe its wrong to do so.
what else can i do???

Macdeployqt doesn't include Phonon in the .app bundle

Hello fellow programmers!
I have written a video player using Qt. Everything works fine on my Mac, but when I use macdeployqt to deploy my application and I open the result, I am getting the following message:
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::AudioOutput ( no objectName ).
WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded
...
And of course it doesn't play audio (in my machine or in another). Maqcdeployqt does include the other parts of Qt and the 3 party libs wo problems. Its just the damm Phonon.
I feel that i'm making a dumb mistake but i just cant find it.
The otool log of my app shows:
#executable_path/../Frameworks/phonon.framework/Versions/4/phonon (compatibility version 4.4.0, current version 4.4.0)
As the only reference of phonon.
I read in the documentation of qt the following:
"The Mac deployment tool can be found in QTDIR/bin/macdeployqt. It is designed to automate the process of creating a deployable application bundle that contains the Qt libraries as private frameworks.
The mac deployment tool also deploys the Qt plugins, according to the following rules:
-Debug versions of the plugins are not deployed.
-The designer plugins are not deployed.
-The Image format plugins are always deployed.
-SQL driver plugins are deployed if the application uses the QtSql module.
-Script plugins are deployed if the application uses the QtScript module.
-The svg icon plugin is deployed if the application uses the QtSvg module.
-The accessibility plugin is always deployed. "
Maybe i have a debug version of phonon? I don't know, i have tried to deploy the debug and the release versions and none have worked.
Also i founded a related problem in this page:
http://www.justinfx.com/tag/phonon/
So i included a folder named 'PlugIns' in my bundle with the phonon_backened folder from my system inside of it after the deploy: it played audio on my machine (but it didn't play it on another) and my app crashed at the end so that cant be the way.
I'm using c++, Qt 4.8.5, the phonon from the SDK (i didn't install any version of phonon, i just installed Qt), and Mac OS X (10.6.8)
I would love to hear any idea or suggestion.
Thanks in advance.
I didn't find the source of the error, but I bypassed it by macdeploying the phonon example from the qt examples folder on another Mac (i.e. Lion). It included the folder 'Plugins' inside the bundle with all the phonon stuff, so I include now that folder into the bundles macdeployed in my Snow Leopard manually. It is ugly but it works from now.
If anyone knows the way to really fix the issue I will be happy to hear it.
I used py2app (neither pyinstaller nor cx_freeze worked) and it created the app distribution folder almost perfectly, except it did not copy the phonon backends. Running macdeplpyqt did not help.
The location of your plugins in your app structure is MyApp.app/Contents/PlugIns so I copied over the folder from Qt install (/Developer/Applications/Qt/plugins/phonon_backend/ ) into the PlugIns folder. That still gave the same error.
Digging in further I saw that MyApp.app/Contents/Resource/qt.conf file is expecting the plugins to be in the Resource/qt_plugins folder so I made a symbolic link from from PlugIns MyApp.app/Contents/PlugIns to MyApp.app/Contents/Resource/qt_plugins and everything works now.

Qt on Mac: where to find "configure"

I am very new to Mac.
I downloaded QT SDK Mac Open source (http://get.qt.nokia.com/qtsdk/qt-sdk-mac-opensource-2010.02.dmg) and installed the Package.
I can run qmake, build samples and run demos,
but I cannot run configure (in order to build the Qt libraries statically).
It says: -bash: No such file or directory.
Documentation says I should run this in the "Qt root folder", but what is this folder in Mac?
I looked for it in /usr/bin, /usr/local/Qt4.6, /Developer/Tools/Qt.
Anyway, what is "configure" on Mac. is it an executable or a script?
Thanks a lot
The SDK download is a pre-built binary library. You need to download the source code version of Qt to be able to configure it to build as static libraries.
The configure script only comes with the source code download version.
I think the SDK only provides the headers and libraries hence the reason you can build applications using Qt. To build Qt itself you will need the source package which is a different download.

How to deploy my application using Qt-Creator?

I'm trying to deploy my simple Qt project like a hello world.
I build it successfully and can also execute it on Qt-Creator. However, I can't execute the binary directly in the release folder due to some shared library errors.
So I just copy some essential librarys to the release folder such as qtcore.dll and qtgui.dll, but I can't still execute it.
How can I deploy my simple Qt project? Is there an another step to deploy it?
You also need to deploy the MINGW runtime dll (mingwm10.dll). This file is located in your Qt\2009.5\mingw\bin directory.
Also pay attention to whether your application is compiled in debug mode or release mode. I just made the test with an hello world type application and Qt Creator. In the debug folders, I copied libgcc_s_dw2-1.dll, mingwm10.dll, QtCored4.dll and QtGuid4.dll and it works.
Pay attention to the d in dll names, which stands for debug: QtCore d 4.dll.
See Qt 4.6: Deploying an Application in Windows.
For Qt 5, check this page.
If you don't want to have dependencies with qt/mingw dlls you should compile qt statically as explain here: http://qt.nokia.com/doc/4.6/deployment-windows.html#static-linking.
You may also use static linking, just add this line into the .pro file:
QMAKE_LFLAGS += -static-libgcc
I found the solution here and successfully tested on WinXP with QT creator 2.2.0
Try running dependency walker on it (http://dependencywalker.com/) to see which dlls are missing?
Generally, you won't need to move those Qt libraries into your local folder since the Qt installation should've added those libraries into your path.
One possibility is that you built debug, and the Qt debug dlls are named differently
copy all the qt dlls to your windows directory directly "C:\Windows\" and there will be no qt dll error
100% working and simple
nb: do not create a qt dll folder in your windows directory post them as they are

Resources