Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtQuick project with qt-components symbian



  • Hi all,
    i'm trying that above in my project...well
    i've a big problem at run-time: ReferenceError: Can't find variable: checkUtil

    Ok, i'm not so newbie with that, but this is my initial code (in main.cpp):
    @
    QmlApplicationViewer viewer;
    MyClass checkUtil;

    viewer.setMainQmlFile(QLatin1String("qml/Repos/main.qml"));
    viewer.rootContext()->setContextProperty("checkUtil", &checkUtil);
    

    @

    So my var is declared and setted into context!



  • Are you able to reference checkUtil inside your qml code??

    Can you try below code...
    @QmlApplicationViewer viewer;
    MyClass checkUtil;
    viewer.rootContext()->setContextProperty("checkUtil", &checkUtil);
    viewer.setMainQmlFile(QLatin1String("qml/Repos/main.qml"));
    @
    Just moved setContextProperty() above setMainQmlFile() :)



  • Ok... just tried out in my Qt Creator, the above should solve your problem. Basically you are setting contextProperty before its being referenced inside your qml file.



  • Damn!
    it obviously doesn't work if i set it after!!!
    thanks mate!



  • ohhh it's very beautiful work with QtQuick and Symbian/Meego components!
    I'm looking forward to stable components...


Log in to reply