Deployment on Windows - app runs but doesn't show
-
Windows 7, Qt 5.7.0 mingw. I'm trying to deploy a qml app for Windows, using the windeployqt. So far I have succeeded to start the app so that it runs without complaining about missing dll's or anything. These are the first lines of the cpp code:
int main(int argc, char *argv[]) { std::cout << "MAIN has started" << std::endl << std::flush; qDebug() << "MAIN has started"; qSetMessagePattern("%{function} %{line}: %{message}"); Tools* tools = new Tools(); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling, Tools::getUiScaling()); QQuickStyle::setStyle(Tools::getStyle()); std::cout << "app will be created"<< std::endl << std::flush; QApplication* app = new QApplication(argc, argv); QQmlApplicationEngine* engine = new QQmlApplicationEngine(); QQmlContext* ctx = engine->rootContext(); Connection* conn = new Connection(); ProfileData* data = new ProfileData(ctx, conn); Monitoring* monitoring = new Monitoring(conn); std::cout << "app classes were created"<< std::endl << std::flush; ctx->setContextProperty("qApplication", app); ctx->setContextProperty("profileData", data); ctx->setContextProperty("connection", conn); ctx->setContextProperty("tools", tools); ctx->setContextProperty("monitoringData", monitoring); std::cout << "appengine will be created"<< std::endl << std::flush; engine->load(QUrl(QStringLiteral("qrc:/main.qml"))); qDebug() << "EXECUTE APP"; std::cout << "app will be executed"<< std::endl << std::flush; int exitcode = app->exec(); // 1 means "restart" qDebug() << "APP WAS EXECUTED";
and this is the output when I start the app from the (cygwin) command line:
MAIN has started app will be created app classes were created appengine will be created app will be executed
Then nothing else happens; the application is still running, but it doesn't use CPU or do anything else. If I run it from QtCreator it behaves normally, first it prints
MAIN has startedMAIN has started
as expected and then works fine (opens a window etc.). This fine working .exe I have copied to a new directory where I run
windeployqt.exe --qmldir ../projectsrc/ ./
I just have to copy some non-qt .dll's from the Qt's bin directory manually. But even copying all of the .dll's from bin/ doesn't help.
These are the directories created by windeployqt: bearer/ iconengines/ imageformats/ Material/ platforms/ private/ qml/ qmltooling/ Qt/ QtGraphicalEffects/ QtQml/ QtQuick.2/ QtQuick/ translations/ Universal/. I think it should be all that's needed, I don't use any plugins or fancy extra.
-
I finally found out the reason. I started the .exe from QtCreator as an external app and the debuggin message told that module QtQuick.Controls is not installed. Windeployqt.exe didn't deploy the necessary files, I don't know why. It was solved by manually copying 5.7\mingw53_32\qml\QtQuick\Controls\ to the target QtQuick\Controls.