How to do a qml "import" with assets?

368 views
Skip to first unread message

Koying

unread,
Nov 18, 2011, 8:39:11 AM11/18/11
to andro...@googlegroups.com
I have a "components" subdir in my "qml" dir.
On the other platforms (and with qml as resources), I can do an 'import "components" as Cp' to make the components in the subdir available.

It doesn't seems to work on Android with assets...

For info, I set my main qml file with:
viewer->setMainQmlFile(QLatin1String("qml/main.qml"));

Message is:
W/Qt      (10564): file:///qml/main.qml:5:1: "components": no such directory
W/Qt      (10564):      import "components" as Cp
W/Qt      (10564):      ^

In the .apk, "main.qml" is in "assets/qml/main.qml" and the components in "assets/qml/components/*"

BogDan Vatra

unread,
Nov 19, 2011, 2:45:53 AM11/19/11
to andro...@googlegroups.com
Hi,

You also need to get rid of "file://" thing by adding :
viewer->engine()->setBaseUrl(QUrl::fromLocalFile("/"));
after you set your main qml file.

Cheers,
BogDan.

2011/11/18 Koying <cb...@semperpax.com>:

Reply all
Reply to author
Forward
0 new messages