PDA

View Full Version : Validate TextField



porterneon
12th November 2014, 15:57
Hi
I would like to create simple edit form for text and double values.

For text field I'm using RegExpValidator:

TextField {
id: itemNazwa
width: 200
height: 20
focus: true
maximumLength: 30
validator: RegExpValidator { regExp: /[0-9a-fA-F\s]{1,30}/; }
}

and for double value I'm using DoubleValidator:

TextField {
id: itemCenaNetto
width: 200
height: 20
text: qsTr("---")
validator: DoubleValidator { bottom: 0; top: 1e10; decimals: 2; }
}

What I found out is that validator is working only when text field is empty and user starts to input some text. If there is already some text in text input field validators are not working, user is able to input any values into text field.

I would like to set current values on form load and allow user to edit those values in validated fields. How to correctly implement input form with validation?