Skip to content

Instantly share code, notes, and snippets.

@FONQRI
Created March 16, 2023 04:25
Show Gist options
  • Save FONQRI/09cddbeee2ea6eb2794dd6108656ab97 to your computer and use it in GitHub Desktop.
Save FONQRI/09cddbeee2ea6eb2794dd6108656ab97 to your computer and use it in GitHub Desktop.
Triangle.qml for tutorial in moderncpp.ir
// RectangleExample.qml
import QtQuick 2.5
// The root element is the Rectangle
Rectangle {
// name this element root
id: root
// properties: <name>: <value>
width: 120; height: 240
// color property
color: "#4A4A4A"
// Declare a nested element (child of root)
Image {
id: triangle
// reference the parent
x: (parent.width - width)/2; y: 40
source: 'assets/triangle_red.png'
}
// Another child of root
Text {
// un-named element
// reference element by id
y: triangle.y + triangle.height + 20
// reference root element
width: root.width
color: 'white'
horizontalAlignment: Text.AlignHCenter
text: 'Triangle'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment