I have textInput box:
TextInput {
x: 5
y: 2
maximumLength: 16
width: maximumLength * 20
height: 17
focus: false
validator: RegExpValidator { regExp: /\d+/ }
KeyNavigation.down: amount
}
And a clear button. When I click on clear button it should clear the text input box. How to do it?
You have to add the id
property to your TextInput
element.
TextInput {
id: mytextbox
x: 5
y: 2
...
}
And on the event click of your MouseArea
for your clear button you can do:
onClicked: {
mytextbox.text = "0";
}