Plugin is not recognized in QML Desktop Appication Deployment - qt

I have wrote a Qt Quick Desktop application in c++ qnd Qt Creator(QML) on Windows7. Now I have to deploy it.
I'm using Qt Quick Desktop Components plugin in my application, I've installed it according to these instructions, and I'm using it with:"import Qt.labs.components", as written there.
I tried adding to the .pro file:
QML_IMPORT_PATH = C:\QtSDK\Desktop\Qt\4.7.4\mingw\imports\Qt\labs\components
but I saw it's working well without it, and I removed it.
I've read a guide how to deploy such an application here, and followed it; I have now a deployment folder, with: the .exe file, the needed dll's, and a folder hierarchy like:Qt/labs/components.
in components I put the styleplugin.dll(for desktop components), and a qmldir file, with the content: plugin styleplugin, excactly like in the doc.
but when I'm runnig my application.exe from the deployment folder in another computer, I'm getting a white, empty window, means: It didn't find the .dll file.
Should you explain me please what's wrong?

I know two reasons, when app can not load plugin dll:
Some of dependecies of the plugin dll are missing or can not be found and that is why it can not be loaded. Qt Creator or Visual Studio environment can be different than the system one. For example, your IDE can modify PATH environment variable. Check plugin's dependencies availability with Microsoft Dependency Walker tool in the same environment where you launch your app.
App can not find plugin in standard directories. To check this you should specify plugin import directory explicitly:
QDeclarativeView *rootView = new QDeclarativeView()
rootView->engine()->addImportPath(QLatin1String("path/to/your/imports"));

Related

Deploy QML application with localstorage plugin

I have deployed a QML application (static build on windows, following this how-to: http://qt-project.org/wiki/How-to-build-a-static-Qt-for-Windows-MinGW). However, the qml_import_trace (screenshot below) reveals that LocalStorage is loaded from the Qt/Static folder on the development computer, not from the release folder. Hence, when launched at another computer, the LocalStorage module is not found. How may the LocalStorage plugin/module be shipped with the application?
Including the following lines in the .pro files will give svg support. Am I only missing a qtplugin for sql/localstorage? In that case, what is the proper plugin name? Also, where can I find valid inputs for QTPLUGIN+= and QT+= ?
QTPLUGIN += qsvg
QT += svg sql
If I understand you correctly you want to copy the needed files to the release folder automatically.
Use the windeployqt.exe (in qt/bin folder) with --qmldir option. It will scan the given path for QML files and collect the QML components imported in those files.
A solution, although not optimal, was to manually copy the QtQuick/LocalStorage folder from the static folder into the release folder

Qt can't access some .dll files

I am working on a plugin for some application, and I am using libtiff. The filter is working just fine, but there is a problem. There are some .dll files that have to be included in compile path. When I add those .dlls in \QtSDK\Desktop\Qt\4.8.1\mingw\bin the plugin is working fine, but when i delete one or more of those .dlls, plugin is not recognised by the application. Those .dll are not included in the Qt SDK by default.
Is there any way I can include those .dll in my plugin and add a path to them without copying them to the Qt SDK bin folder.
Usually I add my plugins to my application directory and add this line of code to main() in main.cpp like so:
qApp->addLibraryPath(QString("."));
Image plugins go in imageformats and SQL drivers (ODBC) go in sqldrivers. You can make the library path anything you want relative to your application root directory. I like to keep things simple and just reference the root directory.

Deploying Qt C++ Application from Visual Studio qwindows.dll error

I've been googling for a solution to this issue and although I've found many people sharing my problem none of their solutions work for me.
I wrote a C++ application using Qt framework using Visual Studio 2010. I built and ran the application in "Release" mode from Visual Studio without issue, but when I copy that exe from the Release folder to a new destination (pretend its a new PC) it fails to run providing this error:
---------------------------
TestApplication
---------------------------
This application failed to start because it could not find or load the Qt platform plugin "windows".
Available platform plugins are: windows.
Reinstalling the application may fix this problem.
Within the executable directory I have the following file structure:
./TestApplication.exe
./libGLESv2.dll
./Qt5Core.dll
./Qt5Gui.dll
./QtWidgets.dll
./platforms/qwindows.dll
./qt.conf
All dll files were taken from the 5.0.0 build of Qt in the Qtbase folder where the libraries reside.
The qt.conf file is:
[Paths]
Plugins=.
Without it, the launch error is the same except it says "minimal" and "offscreen" are available platforms as well.
For all other people experiencing this error it seemed to be solved by creating the platforms folder and putting in the qwindows.dll. But doing that myself doesn't change any behavior.
Is there something I've done wrong? Perhaps my method of generating the .exe in the first place is wrong?
If you are using libGLESv2.dll, then you must include libEGL.dll, too.
You can't see that in depends.exe, don't know how the Qt developers managed to hide this.
If your Qt is out of the box, then both Dlls are necessary even if you are not using OpenGL.
Also, if your Qt is out of the box, you need to include also the three ic*.dll, which contain information for Unicode handling.
You can see which DLLs are needed by looking at which ones are invoked when running Debug (F5) in Qt Creator.
=Carl
The release is likely missing a library/plugin or the library is in the wrong directory and or from the wrong directory.
Qt intended answer: Use windeployqt.
Qt comes with platform console applications that will add all dependencies (including ones like qwindows.dll and libEGL.dll) into the folder of your deployed executable. This is the intended way to deploy your application, so you do not miss any libraries (which is the main issue with all of these answers). The application for windows is called windeployqt. There is likely a deployment console app for each OS.

Why Qt plugins compiled as .so don't work when deployed in a MacOSX bundle?

I have a CMake project for a Qt based application using plugins.
The standard way to create a plugin is CMake (on all platforms) is with:
ADD_LIBRARY(${PROJECT_NAME} MODULE ...)
This creates a libxxx.so plugin (instead of a libxxx.dylib, if SHARED is used instead of MODULE above).
Now, when running inside an IDE like Xcode or QtCreator, the application works fine, the plugin is loaded and works.
But if I create the .app bundle, the application does not start, saying "libxxx.so is not a valid Qt plugin"! How could be that possible? Maybe some library dependency is not found, but how can i check that? I have used tool -L and I think all the libraries are ok.
You may need a "qt.conf" file in your bundle to tell Qt where the plugins are.
You should read up on CMake's BundleUtilities fixup_bundle function and let it do all that "otool -L" and "install_name_tool" stuff for you.
See this recent related stackoverflow question and answer:
CMake: Copy Frameworks into App Bundle

QWT plugin for QT 4.5

I have gotten the latest QWT 5.1.2 for QT 4.5 and managed to get it to complie. I am now trying to get the plugin to work in QT Designer (with VS intergration). I have placed the plugin files into the plugin/designer folder, but when attempting to load, I hit this error
Cannot load library qwt_desginer_plugin5.dll: The specified module cannot be found.
I've done some search on this issue, one page which suggest moving the plugin to the VS intergration folder - which does not exist for Program Files\Nokia\Vs4Addin.
My QT Designer is a debug-and-relase build. (That is, if I use a debug build of the plugin it would complain that it is expecting a release).
qwt_designer_plugin5.dll depends on qwt5.dll, so:
Additionally to placing "qwt_desginer_plugin5.dll" in "plugins\designer" directory, you must put qwt5.dll to some place where windows loader can find it (at example, you can put it in "%QTDIR%\bin" directory)
It appears that I have to place the generated dll into the qt\bin folder for the designer to load the plugin
You may place it everywhere in the PATH. Also the same dir as the executable program works.
You can see how dll libraries are loaded.

Resources