Вопрос

I want to communicate between C++ and QML on Meego. It happens using C++ QML binding as described in this link.

When I run an app on the Symbian platform it works, and data from C++ is available to manipulate in some QML file.

But on Meego it always says myItem.qml file not found.

See the following code snippet:

int main(int argc, char *argv[]) {
     QApplication app(argc, argv);

     QDeclarativeView view;
     MyClass myClass;
     view.rootContext()->setContextProperty("myObject", &myClass);

     view.setSource(QUrl::fromLocalFile("MyItem.qml"));
     view.show();

     return app.exec();
 }

Does Meego does not support QML C++ binding?

I also tried to give the exact path of the QML file but never found that file, even myItem is in project structure.

Is there some thing associated with path settings in .pro file etc

Please help on this as I am stuck here with this and cannot move forward in my app using Qt Quick.

Это было полезно?

Решение

Yes, but your problem isn't related to C++ and QML bindings. Your application (specifically the view) can't find the .qml file to load.

By default, I think on meego the default path to look in is ../qml. So by default you should be packaging into /opt/YOURNAME with the binary in /opt/YOURNAME/bin and the qml files in /opt/YOURNAME/qml.

However, you can also put the qml files into a resource and use the :/ paths to access a resource instead.

IE, in your resource file:

<RCC>
    <qresource prefix="/">
        <file>qml/foo.qml</file>
    </qresource>
</RCC>

And in C++:

viewer.setSource(QUrl("qrc:/qml/foo.qml"));
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top