Let me use an example to explain the issue.
If we have a TextField
like this,
TextField {
text: "0.0"
validator: DoubleValidator { bottom: -359.9;
top: 359.9;
decimals: 1;
notation: DoubleValidator.StandardNotation }
onEditingFinished: {
console.log("I'm here!");
}
}
We can type numbers such as 444.9
, 399.9
or -555.5
. As you can see, the values are not between -359.9
and 359.9
.
In the documentation we can find the following information:
Input is accepted but invalid if it contains a double that is outside the range or is in the wrong format; e.g. with too many digits after the decimal point or is empty.
I thought DoubleValidator
didn't accept this kind of things, but unfortunately it does.
So I suppose the solution would be to check the final input, but again we have a problem: editingFinished
is only emitted if the validator returns an acceptable state and this is not always the case.
Perhaps I'm not doing a good approach, I'm not understanding how to use DoubleValidator
or maybe I need some code in C++.
By the way, I'm working with Qt 5.4.
TextField
shows that value and if I press enter or change to anotherTextField
in the window, the data is not cleared. Do you have a little example to test what you said? – Especial