Qt World Summit: Submit your Presentation

Project doesn't work on device when using Resource file

  • hello,

    I have a QML project which uses couple Qt modules (to handle network and location). Project is ready for deployment and now it is time to make it work with resource file. project name is similar to "MyProject" (uses capital letters in project name).

    DEPLOYMENTFOLDERS is commented out in .pro file and source (in main.cpp) is set to QRC: viewer->setSource(QUrl("qrc:/qml/MyProject/main.qml"));

    .qrc file is created and works perfectly in simulator.

    now, when i try to run my project on Harmattan device, I got errors related to Qt modules:
    @qrc:/qml/MyProject/screens/PageSplash.qml:58: ReferenceError: Can't find variable: networking
    qrc:/qml/MyProject/screens/PageSplash.qml:61: ReferenceError: Can't find variable: networking@

    Question: what should i check to be sure that i prepared everything to use resource file and what might cause errors on device if everything is OK in simulator?

  • As per the error message PageSplash.qml is successfully loaded from resource file, as it is able to parse it and report a reference error. The error has something to do with your qml code. It would be more helpful if you can paste some code where your are using variable "networking".

  • PageSplash.qml:

    @ Component.onCompleted: {
    // Page element completed
    Connections {
    target: networking

    Networking is defined in main.cpp as:

    @#include <networking/networking.h>
    networking networkHandler;
    QDeclarativeContext *ctxt = viewer->rootContext();
    ctxt->setContextProperty("networking", &networkHandler);@

  • Looks like networking context property is not set properly. I set context properties before using setSource() on viewer, I remember some issue with when used after setSource(). To be sure that networking is set properly or not print it in console.

  • networking is set before setSource().

Log in to reply