Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Difficulty to enter negative numbers in TextEdit, TextInput etc... boxes.
Forum Updated to NodeBB v4.3 + New Features

Difficulty to enter negative numbers in TextEdit, TextInput etc... boxes.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 622 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Francky033
    wrote on last edited by Francky033
    #1

    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!

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      How are you validating the range/negative numbers?

      As per documentation;

          TextField {
              validator: IntValidator {
                  bottom: -99
                  top: 99
              }
              focus: true
          }
      

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      1
      • F Offline
        F Offline
        Francky033
        wrote on last edited by Francky033
        #3

        Yes, that's right, but that doesn't change anything... I can enter a negative value but in a rather convoluted way.

        1 Reply Last reply
        0
        • MarkkyboyM Offline
          MarkkyboyM Offline
          Markkyboy
          wrote on last edited by
          #4

          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?

          Don't just sit there standing around, pick up a shovel and sweep up!

          I live by the sea, not in it.

          1 Reply Last reply
          1
          • F Offline
            F Offline
            Francky033
            wrote on last edited by
            #5

            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 !

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved