Important: Please read the Qt Code of Conduct -

Accessing QML objects from .rcc files from Loader objects

  • Hi,

    I am building a modular app that can use modules for example a Clock and I would like to distribute these modules as .rcc files.
    Everything is fine when I display the Clock in regular QML files but if I load a file with Loader it doesn't recognize the Clock object.
    In my main.cpp


    In my main.qml

    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.2
    ApplicationWindow {
        id: window
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        Row {
            Clock {
                //This Clock works
            Loader {
               id: myLoader
               source: "./layout/test.qml"

    In ./layout/test.qml

    import QtQuick 2.0
    Item {
        Clock {
           // does not work

    It throws the following error: Clock is not a type

    Does somebody have a good idea how can use the Clock module from the loaded QML file?

  • Answering my own question again.

    import "../" in the test.qml helped.

    PS! Thanks to DanChapman

Log in to reply