Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Very simple Rectangle example exiting immediately after app runs
Forum Updated to NodeBB v4.3 + New Features

Very simple Rectangle example exiting immediately after app runs

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 217 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by
    #1

    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"

    https://github.com/enjoysmath
    https://math.stackexchange.com/users/26327/exercisingmathematician

    1 Reply Last reply
    0
    • enjoysmathE Offline
      enjoysmathE Offline
      enjoysmath
      wrote on last edited by
      #2

      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'
              }
          }
      

      }

      https://github.com/enjoysmath
      https://math.stackexchange.com/users/26327/exercisingmathematician

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved