[Qt-creator] [Interest] QML dir hierarchy

Nuno Santos nunosantos at imaginando.pt
Thu Jan 5 10:14:32 CET 2017


Keep your qml resources inside folders

/
/resources
/resources/icons
/resources/images
/resources/qml
/resources/fonts

create a .qrc file on the .pro dir or inside resources.

Open .qrc with editor and choose to add existing files. Select the files inside the dirs (icons, images, qml, fonts). 

The files will automatically be added with the respective paths as prefix.


> On 05 Jan 2017, at 08:58, Kristoffersen, Even (NO14) <Even.Kristoffersen at Honeywell.com> wrote:
> 
> Note, this won't help with the QRC view unfortunately, it will still display as path list instead of folderized.
> 
> If you want to keep using the QRC view only then you have to use prefix as you mentioned, but I believe you have to import the prefix. Maybe this was the cause of the error you saw.
> 
> Another option is to use the OTHER_FILES option in your .pro file.
> 
> OTHER_FILES += \
>    RES/qml/*.qml \
>    RES/qml/Components/*.qml \
>    RES/qml/Screens/*.qml
> 
> This will add a folderized QML folder in your project explorer.
> 
> 
> -Even
> 
> -----Original Message-----
> From: Interest [mailto:interest-bounces+even.kristoffersen=honeywell.com at qt-project.org] On Behalf Of Kristoffersen, Even (NO14)
> Sent: 5. januar 2017 09:07
> To: interestqt-project.org <interest at qt-project.org>; qt-creator <qt-creator at qt-project.org>
> Subject: Re: [Interest] QML dir hierarchy
> 
> Try putting your QML files in subfolders.
> You will probably want to do this sooner or later anyway to keep your source tree manageable as the project grows.
> 
> Just beware that you then have to import the folder of the components you are using from within the QML files unless they are in the same folder.
> IE. import "../Components" from your screen files.
> 
> -Even
> 
> -----Original Message-----
> From: Interest [mailto:interest-bounces+even.kristoffersen=honeywell.com at qt-project.org] On Behalf Of Jason H
> Sent: 4. januar 2017 16:44
> To: interestqt-project.org <interest at qt-project.org>; qt-creator <qt-creator at qt-project.org>
> Subject: [Interest] QML dir hierarchy
> 
> I am cross posting this to QtC and Interest because it's a combinational issue. 
> 
> My QML projects are getting sizable, I'd like to start breaking my QML resources down in a hierarchy, but my attempt at that has failed.
> Given:
> 
> qml.qrc /
> - app.js
> - Screen1.qml
> - Component1.qml
> - Screen1.qml
> - Component3.qml
> - Component4.qml
> - Screen1.qml
> - Component2.qml
> 
> I'd like to break it down into:
> qml.qrc /
> - Screens /
> -- Screen1.qml
> -- Screen1.qml
> -- Screen1.qml
> - Components /
> -- Comoponent1.qml
> -- Comoponent2.qml
> 
> But I was not able to accomplish this in QtC. So I hacked the QRC file to have two prefix entries:  <qresource prefix="/screens"> and  <qresource prefix="/components"> However this resulted in errors.
> 
> Also, in QtC they weren't folderized, they just appeared as screens/Screen1.qml ...
> components/Component1.qml
> ...
> 
> How can I accomplish a folderized QRC? Currently, the filesystem is flat, but I don't mind adding them to actual folders if that would help. 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Qt-creator mailing list