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

Very simple Rectangle example exiting immediately after app runs



  • This screenshot has the full description of what I'm doing:

    a91d16a7-ac59-4c02-ba13-c471342503b2-image.png

    I ran qmake after "adding existing file > S3.png" to the resources.

    The app runs then shows that output below in the screenshot. Not sure what to do, but the example is taken from:

    https://qmlbook.github.io/ch04-qmlstart/qmlstart.html

    "RectangleExample.qml"



  • Stick the whole thing in a Window and it should work:

    import QtQuick 2.12
    import QtQuick.Window 2.12
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle {
            id: root
            width: 120; height: 240
            color: "#4A4A4A"
            Image {
                id: triangle
                x: (parent.width - width)/2; y: 40
                source: "S_3.png"
            }
            Text {
                y: triangle.y + triangle.height + 20
                width: root.width
                color: 'white'
                horizontalAlignment: Text.AlignHCenter
                text: 'Triangle'
            }
        }
    

    }


Log in to reply