[Interest] qt_add_qml_module() RESOURCES vs qt_add_resources()

Sze Howe Koh szehowe.koh at gmail.com
Tue Feb 13 16:38:43 CET 2024


On Tue, 13 Feb 2024 at 22:10, ekke <ekke at ekkes-corner.org> wrote:
>
> Am 13.02.24 um 14:52 schrieb Nils Jeisecke:
> > Hi,
> >
> > On Tue, Feb 13, 2024 at 2:41 PM ekke <ekke at ekkes-corner.org> wrote:
> >> thx. But it's not the prefix. If I add images.qrc and data-assets.qrc to
> >> the executable, it's working.
> > If cmake policy QTP0001 is set to new, the resource prefix defaults to
> > "/qt/qml/", so your previous URIs won't work.
> >
> > Did you check the generated qrc file for paths?
> >
> > Nils
>
> Hi Nils,
>
> the .qrc are ok with pathes. per ex: "qrc:/images/..." finds the
> requested image
>
> QTP0001 is not set to new, because I cannot easy change my file
> structure. (have 20 mobile business apps ported to 6.6 - some grown over
> 6+ years ;-)
>
> think the best is, I create a Bugreport together with a small demo app.
> current work done with 6.6. Before reporting an issue, will test with
> 6.7 beta2 next days. before this, have to finish my QMake-CMake for iOS
> ;-) Android done :)
>
> ekke

Hi Ekke,

There is no bug. If your resource files are part of your QML module,
then they will be in the same folder as your *.qml files. Probably
"qrc:/Main_Module/images/..." in your case.

To list your app's resource file paths, add the following lines to
your main() function:

    QDirIterator qrc(":", QDirIterator::Subdirectories);
    while(qrc.hasNext())
        qDebug() << qrc.next();


Regards,
Sze-Howe


More information about the Interest mailing list