how import other qml files?
Hi all,
How to import other qml files in Qt Quick?
I have created a directory naming core.In this directory,I have a file naming waterpage.qml.I have edited qmldir file,its contents are "WaterPage WaterPage.qml"
In the mainpage.qml,i have coded the following codes:
import "core"
Page{
WaterPage{id:waterpage}
}
But when I run the project, Igot the following error:
Cannot assign to non-existent property "waterpage"
waterpage{id:waterpage}
Why this problem happened?
Thanks for advice.
Re: how import other qml files?
you can add those other qml files in a folder and than import the folder in main file. Like
you have one main.qml file and one other files RssModel.qml file. so first put your rss.qml file in a folder lets name it "common".
than on main.qml file write as below.
[QUOTE]import "common" as Common[/QUOTE]
and access RssModel.qml file in main.qml file after above line like below
[QUOTE]Common.RssModel { id: rssModel }[/QUOTE]
hope you get the point.
Re: how import other qml files?
for demo code example , you can open any code example of qt quick like "flicker" in Qt Studio and check out the code. There you can see how they have use different qml file in main or other qml file.