Solved QQmlContext: Cannot set property on invalid context
-
Hi,
I keep receiving
QQmlContext: Cannot set property on invalid context.
QQmlComponent: Cannot create a component in an invalid contextwhen
component.create();
in the following code is executed.void MainWindow::on_openMapBtn_clicked() { QQmlEngine engine; QMLCommunicationAgent agent; engine.rootContext()->setContextProperty("agent", &agent); QQmlComponent component(&engine, QUrl::fromLocalFile("map.qml")); component.create(); }
What am I doing wrong?
-