qml engine problems
-
Hello guys.
I have the following problem:
class App: public QObject
{
// app methods
}and other class
class MobileApp: public App{
Q_INVOKABLE void method1();
}
in the main.cpp do:
MobileApplicationUI mApp;
// from QML we have access to App as mApp
QQmlContext* context = engine.rootContext();
context->setContextProperty("mApp", &mApp);and when I make the call to mApp.method1() qml engine return the next error:
TypeError: Property 'method1' of object App(0xa2c0646c) is not a function
Thanks
-
Hello guys.
I have the following problem:
class App: public QObject
{
// app methods
}and other class
class MobileApp: public App{
Q_INVOKABLE void method1();
}
in the main.cpp do:
MobileApplicationUI mApp;
// from QML we have access to App as mApp
QQmlContext* context = engine.rootContext();
context->setContextProperty("mApp", &mApp);and when I make the call to mApp.method1() qml engine return the next error:
TypeError: Property 'method1' of object App(0xa2c0646c) is not a function
Thanks
@rodriguezamador90 said in qml engine problems:
QQmlContext* context = engine.rootContext();
context->setContextProperty("mApp", &mApp);It's important to call this method before you set QML source file on the engine. So make sure you call it before calling
engine.load("main.qml").