tags:

views:

47

answers:

1

I am building an application with mixed UI technologies (mostly C++ with some QML components included).

Suppose I have a QML item which I want to show inside a QDeclarativeView using syntax like this:

view = new QDeclarativeView(QUrl::fromLocalFile("foobar.qml"));

I have added foobar.qml to my project in Qt Creator which automatically adds this line to the .pro file:

OTHER_FILES += \
    foobar.qml

Now, you would expect including the file into the project to imply that it should be copied to the build folder, but it doesn't, and I get an error about missing foobar.qml in the build folder when I run the application. I'd hate to add custom build steps just to copy QML sources around, so is there some "de facto" way of doing this?

+2  A: 

One obvious solution would be to include the QML source through Qt's resource system. This is hinted at on the doc page about deploying QML based applications.

EDIT: Here is the complete solution. I should learn to RTFM.

teukkam
This is what I do in my application. Basically something like `view = new QDeclarativeView(QUrl("qrc:/qml/scene.qml"));`
Dan