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. QDoubleValidator not working as expected on QLineEdit
Forum Updated to NodeBB v4.3 + New Features

QDoubleValidator not working as expected on QLineEdit

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 5.6k 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.
  • N Offline
    N Offline
    neel2818
    wrote on last edited by
    #1

    Hi All,

    I have written the following code on QLineEdit.

    QDoubleValidator *doubleVal = new QDoubleValidator( 0.0, 100.0, 2, this );
    lineEdit->setValidator(doubleVal);

    In above code we have set the range from 0 to 100 so when we enter digit above 100 then lineEdit should not allow to enter the value above maximum range as it is right behaviour with the QIntValidator.

    As what i believe is lineedit should not allow to enter the value more then maximum value. Can you please help ?

    Above code allow to enter the value 999999 which is wrong. Help me.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      999999 is neither clearly wrong nor clearly ok. You still can enter 999999e-5 which leads to a valid value.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • N Offline
        N Offline
        neel2818
        wrote on last edited by
        #3

        I have tried to apply below API.

        doubleVal->setNotation(QDoubleValidator::StandardNotation);

        Then it should not allow but it allows again 999

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          999 returns the Intermediate state, you still can make that number acceptable by inserting a decimal point somewhere.

          http://www.catb.org/~esr/faqs/smart-questions.html

          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