Here is the code. Look please at the commented line. Thanks for your help.
//main.qml
import QtQuick 2.3//2.3 sur livre
Rectangle {
width: 360
height: 200
color: "grey"
TextInput {
id: argument1
anchors.left: parent.left
width: 160
anchors.top: parent.top
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "2"
font.pointSize: 18
}
TextInput {
id: argument2
anchors.right: parent.right
width: 160
anchors.top: parent.top
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "2"
font.pointSize: 18
}
Text {
id: result
anchors.left: parent.left
anchors.right: parent.right
anchors.top: argument2.bottom
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "4"
font.pointSize: 24
}
Row {
id: buttonRow
width: 317
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.hotizontalCenter//I added ".horizontalCenter". Now "debugging is enabled"
anchors.bottomMargin: 20
spacing: 20
Button {
id: plusButton
operation: "+"
onClicked: result.text = parseFloat(argument1.text) + parseFloat(argument2.text)
}
Button {
id: minusButton
operation: "-"
onClicked: result.text = parseFloat(argument1.text) - parseFloat(argument2.text)
}
Button {
id: timesButton
operation: "*"
onClicked: result.text = parseFloat(argument1.text) * parseFloat(argument2.text)
}
Button {
id: divideButton
operation: "/"
onClicked: result.text = parseFloat(argument1.text) / parseFloat(argument2.text)
}
}
}
//main.qml
import QtQuick 2.3//2.3 sur livre
Rectangle {
width: 360
height: 200
color: "grey"
TextInput {
id: argument1
anchors.left: parent.left
width: 160
anchors.top: parent.top
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "2"
font.pointSize: 18
}
TextInput {
id: argument2
anchors.right: parent.right
width: 160
anchors.top: parent.top
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "2"
font.pointSize: 18
}
Text {
id: result
anchors.left: parent.left
anchors.right: parent.right
anchors.top: argument2.bottom
anchors.topMargin: 10
anchors.leftMargin: 10
anchors.rightMargin: 10
text: "4"
font.pointSize: 24
}
Row {
id: buttonRow
width: 317
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.hotizontalCenter//I added ".horizontalCenter". Now "debugging is enabled"
anchors.bottomMargin: 20
spacing: 20
Button {
id: plusButton
operation: "+"
onClicked: result.text = parseFloat(argument1.text) + parseFloat(argument2.text)
}
Button {
id: minusButton
operation: "-"
onClicked: result.text = parseFloat(argument1.text) - parseFloat(argument2.text)
}
Button {
id: timesButton
operation: "*"
onClicked: result.text = parseFloat(argument1.text) * parseFloat(argument2.text)
}
Button {
id: divideButton
operation: "/"
onClicked: result.text = parseFloat(argument1.text) / parseFloat(argument2.text)
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks