0

I am developping a desktop application in QtQuick/C++, on windows 10. In main() function, I create a QQmlApplicationEngine, set some other classes as context property to it, and finally load my qml file.

Everything went well since recently, when I realize that, when I launch the application in "deployed" version, this engine has no rootObjects loaded.

However, application is starting with root object when launch in QtCreator, both in debug or release mode.

I log some infos in a separate file, and it appears that the Url loaded is valid, only there is no rootObject, and I need it. I read in doc that load() has to wait for objectCreated signal to be ready for remote urls, but my qml file is local, in resource file. By the way, as the load() stand in main() function, I don't see how to connect objectCreated() to a slot, and where to locate the slot

int main(int argc, char *argv[])
{
  QGuiApplication app(argc, argv);
  QQmlApplicationEngine engine;
  Backend B;
  engine.rootContext()->setContextProperty("backend", B);
  ...
  QUrl Url = QUrl(QStringLiteral("qrc:/qml/main.qml"));
  engine.load(Url);
  if (engine.rootObjects().isEmpty())
  {
    //end up here, only when launching executable stand alone!
    return -1;
  }
  return app.exec();

This was running fine, and I can't see which modifications in my code break the process for stand alone application.

Later in startup process, I scan the qml items of main.qml to retrieve some custom item's info (kind of dynamic process), and I therefore need a root object. Without object to start scan, no use to continue, and my app is shutting down.

1 Answers1

0

Oops, sorry, I did not know all the stuff about deploying qtquick application with windeployqt. The only other app that I have tried was an android app, and the bundle was made directly for android target.