문제

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