QDoubleValidator don´t fix comma and point



  • I am dealing with validation, need to validate a form
    wit integer and doubles.
    put a integer validator, i not need ranges:

    intlineEdit->setValidator(new QIntValidator());
    if a write this number:
    1,23,4,56
    Wen it lost the focus, fix the content to:
    123,456
    that behaviour is nice.

    But in other widget need to validate double with no ranges
    doublelineEdit->setValidator(new QDoubleValidator());
    if a write:
    1,23,4,56.45
    when it lost the focus Nothing Hapen!!.
    1,23,4,56.45

    i dont set InputMask
    How can fix it, i want the same bahaviour like integervalidator.



  • Reading from de docs, QIntValidator has a fixup() function which does fix the contents as you describe. QDoubleValidator however does not provide a fixup() function. So if you would like the same behaviour as QIntValidator, then create your own by subclassing QValidator.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.