Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

import qml files from subfolder fails



  • I have the following project structure:

    d495b363-21ed-4627-b3a0-63386f09e6b9-image.png

    Now in the file calqlatr.qml I want to use the qml files from the subfolder content

    if I add

    import "content"
    

    In calqlatr.qml it looks fine but when I try to run the app i get this error:

    QML debugging is enabled. Only use this in a safe environment.
    qrc:calqlatr.qml:2:1: import "content" has no qmldir and no namespace 
         import "content" 
         ^
    

    What Is wrong here? Whats the correct way to import qml files from a subfolder?



  • Found the issue myself.

    I wrote in the main.cpp:

    view.setSource(QUrl("qrc:calqlatr.qml"));
    

    instead of

    view.setSource(QUrl("qrc:/calqlatr.qml"));
    

Log in to reply