[Solved] QDeclarativeView::setSource not working?
-
wrote on 24 Aug 2010, 10:41 last edited by
Hmm, it seems that using an absolute path works - I guess this might be a bug? Surely it should lookup a qml file the same as it does an image?
@view.setSource(QUrl::fromLocalFile("/Qt/projects/PieChart/app.qml"));@
-
wrote on 24 Aug 2010, 11:34 last edited by
try to put your qml file near binary file and try relative path.
-
wrote on 25 Aug 2010, 09:25 last edited by
So how would I do that in Windows? When building the project, how do I 'export' the QML file to the same location as the binary?
-
wrote on 26 Aug 2010, 01:29 last edited by
An easier solution is to put the QML file into the binary using Qt's resource system. Then you can access it as ":/app.qml" and don't have to worry about placement of the file.
If app.qml references other QML files, they will also need to be compiled in as resources, and with the same relative path as they have now.
-
wrote on 26 Aug 2010, 09:01 last edited by
Thanks! That totally works :)
-
wrote on 23 Sept 2010, 13:14 last edited by
[quote author="aalpert" date="1282786194"]
If app.qml references other QML files, they will also need to be compiled in as resources, and with the same relative path as they have now.[/quote]Just what I needed to know. Thank you!
-
wrote on 13 Oct 2010, 14:26 last edited by
Hi,
with QT 4.7 beta 2: I used a Declarative View to embed a QML GUI in the C++ application - which was working OK. After I installed QT 4.7 Release 2010.05 I have the following problem (I did not change the code):
QDeclarativeComponent: Component is not ready
(<Unknown File>: File error for URL file:///C:/Users/home/git/linuxapp/src/bin/:/qml/gui.qml)It is part of the resources and was working with 4.7 beta 2:
QDeclarativeComponent component(_engine, QUrl::fromLocalFile(":/qml/gui.qml"));Now it tries somehow to load the qml-file directly from the working directory. If I change it to:
QDeclarativeComponent component(_engine, QUrl::fromLocalFile("gui.qml"));
it works if I place the qml-file there - but I need to have it in the binary application as a ressource - not in a separate qml file.Did anybody experience the same problems? How can I make QT 4.7 2010.05 using my ressource file? Tried it on LINUX with cmake and also on Windows using the creator 2.0.1.
Peter
-
wrote on 14 Oct 2010, 07:15 last edited by
tried it with:
QDeclarativeComponent component(_engine, QUrl("qrc:/qml/gui.qml"));
this works ;-)
-
wrote on 19 May 2011, 22:24 last edited by
peter, thanks for your post! :)
-
wrote on 3 Oct 2011, 11:50 last edited by
I thought this didn't apply to me because I wasn't using resources, but this (using QUrl) in fact did the trick! Thank you!