Difficulty to enter negative numbers in TextEdit, TextInput etc... boxes.
-
wrote on 10 Jan 2021, 11:34 last edited by Francky033 1 Oct 2021, 11:35
Hello,
I have some small difficulties when entering negative numbers into TextInput boxes in QML.
If I press the "-", "1", "2", "3" keys successively, I get 123 instead of -123.
The only way to enter "-123" is to type 123 and then click on the beginning of the number and type -.The value -123 is then obtained.Is there something I didn't understand?
Thank you!
-
wrote on 10 Jan 2021, 12:23 last edited by
How are you validating the range/negative numbers?
As per documentation;
TextField { validator: IntValidator { bottom: -99 top: 99 } focus: true }
-
wrote on 10 Jan 2021, 12:28 last edited by Francky033 1 Oct 2021, 12:29
Yes, that's right, but that doesn't change anything... I can enter a negative value but in a rather convoluted way.
-
wrote on 10 Jan 2021, 12:51 last edited by
What you describe is not the case for me when I try the code I posted. I am able to successfully enter '-' '9' '9' '9', which is why I answered you.
Perhaps to post a snippet of your code?
-
wrote on 10 Jan 2021, 13:03 last edited by
Yes! You're right !
In fact, I manage the TextEdit anchor using C++.
I was using the "int" type but it was a mistake!I had to use QString and then convert to integer only if the QString is different from "-" in the loop I use.Thanks Markkyboy for your help !
4/5