Important: Please read the Qt Code of Conduct -

QQMLComponent not showing up in main Window

  • Hi there, I am following the documentation to call a QML component from c++ and display it in the main window:

    In main.cpp i have the following:

    QQmlApplicationEngine engine;
        QQmlComponent component(&engine,
        QObject *object = component.create();

    The path ":/Circle2.qml" as opposed to "Circle2.qml" or "qrc:/Circle2.qml" is the only path that does not generate the error "QQmlComponent: Component is not ready" as described in this post:

    HOWEVER, even without the error, the Circle component does not show up in my main window.

    my main.qml:

    import QtQuick 2.9
    import QtQuick.Window 2.2
    Window {
        visible: true
        width: 640
        height: 300
        title: qsTr("Hello World")
        color: "green"
            //width: parent.width/16
            //height: parent.height/8
            anchors.centerIn: parent

    and my Circle2.qml file:

    import QtQuick 2.4
            width: 50
            height: 50
             color: "darkblue"
             //border.color: "blue"
             border.width: 0
             radius: width*0.5

    Does anyone know why my circle isnt displaying anywhere?

  • This is all I see when i run it:

    0_1537307208470_Screen Shot 2018-09-18 at 5.46.37 PM.png

Log in to reply