Fishing_Cat_:
QQmlApplicationEngine engine;
MyCustomClass myObj;
engine.rootContext()->setContextProperty("myExposedObject", &myObj);
事实上我i这样写碰见了一个问题,就是我在qml中Text { text: myExposedObject.someProperty }会提示someProperty为null
当我使用QQmlApplicationEngine engine;
MyCustomClass* myObj = new MyCustomClass();
engine.rootContext()->setContextProperty("myExposedObject", myObj);时,就没有问题,请问是什么原因