Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rationale for QIntValidator behaviour
Forum Updated to NodeBB v4.3 + New Features

Rationale for QIntValidator behaviour

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 339 Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Bob64
    wrote on last edited by
    #1

    I have hit the issue with QIntValidator that others have reported in the past whereby what seems to be an obviously out of range value is treated as Intermediate. However, other than people pointing out that this is as documented, I haven't seen a rationale for it.

    If I set a lower value of 100 and an upper value of 900, why is 999 Intermediate? The rationale in the documentation is that I haven't necessarily finished typing and I could add another digit to make it correct:

    "This is intended because the digit that prevents a number from being in range is not necessarily the last digit typed."

    So what digit could I add to 999 to make it correct? Surely any further digit will make it greater than 999.

    JonBJ 1 Reply Last reply
    0
    • B Bob64

      I have hit the issue with QIntValidator that others have reported in the past whereby what seems to be an obviously out of range value is treated as Intermediate. However, other than people pointing out that this is as documented, I haven't seen a rationale for it.

      If I set a lower value of 100 and an upper value of 900, why is 999 Intermediate? The rationale in the documentation is that I haven't necessarily finished typing and I could add another digit to make it correct:

      "This is intended because the digit that prevents a number from being in range is not necessarily the last digit typed."

      So what digit could I add to 999 to make it correct? Surely any further digit will make it greater than 999.

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @Bob64
      IIRC it's because you could change, say, the first of those digits to 8 to make it 899.

      I don't defend Qt's validators/intermediates, they seem "odd" to me, but I think you will find they work as they do and you have to live with them as they are not going to get changed. I don't know that you will get a terribly good "rationale" :)

      B 1 Reply Last reply
      0
      • JonBJ JonB

        @Bob64
        IIRC it's because you could change, say, the first of those digits to 8 to make it 899.

        I don't defend Qt's validators/intermediates, they seem "odd" to me, but I think you will find they work as they do and you have to live with them as they are not going to get changed. I don't know that you will get a terribly good "rationale" :)

        B Offline
        B Offline
        Bob64
        wrote on last edited by
        #3

        @JonB Thanks. Glad it's not just me!

        What you suggest sounds more like a significant edit rather than just typing another digit as implied by the docs. You have to move around in the string, delete a digit, and add a new one. In that case, you might as well make something like "101q" Intermediate as it only needs a single backspace from the current cursor position.

        JonBJ 1 Reply Last reply
        0
        • B Bob64

          @JonB Thanks. Glad it's not just me!

          What you suggest sounds more like a significant edit rather than just typing another digit as implied by the docs. You have to move around in the string, delete a digit, and add a new one. In that case, you might as well make something like "101q" Intermediate as it only needs a single backspace from the current cursor position.

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by
          #4

          @Bob64
          I might be wrong :) But is it/I think it is that you can change one digit in 999 to make it 899 and so legal. Your 101q cannot be done with a one-digit-change, it requires a one-digit-delete, and I think that difference is significant (to Qt).

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SimonSchroeder
            wrote on last edited by
            #5

            It is really annoying (as a user) if you could not type in 999 and then change it to 899 later. If you're in the flow it is not directly obvious why this should fail, even if the upper limit is 900. We have some checks of floating point input fields in our software ported several times from other GUI frameworks that get really annoying at times. So, I am advocating for this kind of editing behavior. Yes, it makes the programmer's job harder, but it is worth it for the end user.

            1 Reply Last reply
            1

            • Login

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