PDA

View Full Version : QML with setContextProperty deployment



curtis
9th November 2015, 23:00
Hello,

I have a Qt Quick app that uses MSVC 2013 64 bit Qt 5.5. Following these instructions http://doc.qt.io/qt-5/windows-deployment.html (http://doc.qt.io/qt-5/windows-deployment.html) the app deploys and runs OK. If an object is created in C++ and setContextProperty is used the app runs OK in Qt Creator. But when deployed no window is shown and it has to be exited by ending it in Windows task manager. What is needed to deploy with setContextProperty?




QQmlEngine engine;

MyObject myObject;
myObject.initialize();

engine.rootContext()->setContextProperty("myObject", &myObject);

QQmlComponent component(&engine, QUrl(QStringLiteral("qrc:/main.qml")));
QObject *context = component.create();

return app.exec();

anda_skoa
10th November 2015, 10:17
Hmm, are you sure this is related to the context property and not just missing dependency for, e.g. QML or QtQuick?=
I.e. have you tried with an empty window or a window that has content but just doesn't depend on the context object?

Cheers,
_

curtis
11th November 2015, 00:58
Thanks for the feedback, this was a missing dependency and not directly from setContextProperty.

Thanks again