Skip to content

Commit

Permalink
Make the QML example a bit more idiomatic
Browse files Browse the repository at this point in the history
* Conversion from int to string happens implicitly
* Rely on the binding to re-evaluate instead of assigning to label.text
  • Loading branch information
bjorn committed May 5, 2021
1 parent a340655 commit 164b215
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Qt5/OnlyQML/Counter/counter.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ Window {
visible: true

property int counter: 0

RowLayout {
id: layout
anchors.fill: parent
spacing: 6

Label {
id: theCount
text: String(counterWindow.counter)
text: counterWindow.counter
}

Button {
id: theButton
text: "Increment"
onClicked: theCount.text = String(++counterWindow.counter)
onClicked: ++counterWindow.counter
}
}
}
Expand Down

0 comments on commit 164b215

Please sign in to comment.