Nominate our 2022 Qt Champions!

Very simple Rectangle example exiting immediately after app runs

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


    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:


  • 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