Unable to use absolute file paths in qrc file?

This comment applies to Qt5.6.3.

It appears that the quick compiler doesn’t generate proper namespaces when using full paths in a qrc file. I was attempting this because I need to autogenerate a qrc file in the binary folder. The sources are passed to a function to then create the qrc file. The quick compiler runs but produces invalid C++ like this when full paths are used:

Somewhere else in the documentation I thought I saw that colons ‘:’ were translated to underscores ‘_’ to avoid this. Is this just a case of using a pretty old version of the quick compiler that this happens?

namespace QtQuickCompilerGeneratedModule
    namespace _ImportFiles_C:_Projects_AEPP_eSW_Qt_AEPPApps_ImportFiles_ImportGraphicFileLister_qml
        extern const unsigned char qmlData[];
        extern AOTFunction moduleFunctions[];
        QV4::CompiledData::CompilationUnit *createCompilationUnit() { return ::createCompilationUnit(reinterpret_cast<const QV4::CompiledData::Unit*>(qmlData), moduleFunctions); }
        const QQmlPrivate::CachedQmlUnit unit = {
            reinterpret_cast<const QV4::CompiledData::Unit*>(qmlData), &createCompilationUnit, &::loadQmlIR


This really feels like a Qt bug to me. Is this fixed with newer Qt versions?

1 Like

I don’t currently have a good version to test this with. I’d need to pull down something late in the Qt5 version series. I currently have 5.6.3 and 6.2.1. With 6.x the means of compiling resources is different with qt_add_qml_module.

I’ll try to remember to test on my home machine later today where I have 5.15 installed already.

FWIW I was able to work around the issue by letting CMake calculate the relative paths for me.

This does seem to be something for the Qt folks to respond to rather than being anything specifically that CMake is doing. I did cover the new way Qt 6 handles resources in my Qt World Summit 2021 talk. Not sure if that is directly relevant to your query here, but maybe it provides some ideas. The bit about resources starts around the 11 minute mark or so. You might also be interested in the QML part starting around 19:30.

I suggest you follow up in the Qt forums or their issue tracker if the above talk doesn’t get you there.

1 Like

Yes, of course. I don’t even know why I came here first. I think because I had CMake on the brain from something else I was figuring out.

Great talk by the way

1 Like