Skip to content

Instantly share code, notes, and snippets.

@crusj
Last active July 19, 2019 10:19
Show Gist options
  • Save crusj/5425da89ea45104c9264f933241bbf64 to your computer and use it in GitHub Desktop.
Save crusj/5425da89ea45104c9264f933241bbf64 to your computer and use it in GitHub Desktop.

property attributes

property type

  • int
  • real
  • string
  • list
  • qml object type
  • qml basic type

assign

  • static value
  • binding expression

property list

    property list<Rectangle> childRects: [
        Rectangle { color: "red" }
        Rectangle { color: "blue" }
    ]

property alias

can not have explict type specification

   property alias color: retangle.border.color
   Retangle {
        id: retangle
   }

readonly property

readonly property must assign a value and can not be changed

readonly property int someNumber: 10

signal attibutes

signal hanlder

* onClicked

defined signal attribute

signal handler attritute

Rectangle {
    signal activated(real xPosition, real yPosition)
    signal deactivated
    MouseArea {
        anchors.fill: parent
        onPressed: parent.activated(mouse.x, mouse.y)
        onReleased: parent.deactivated()
    }
    onActivated: console.log("Activated at" + xPosition + "," + yPosition)
    onDeactivated: console.log("Deactivated!")
}

property change signal handler

TextInput {
    text: "change this!"  
    onTextChanged: console.log("Text has changed to:", text)
}

method attributes

attached property and attached signal handlers

enumeration attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment