Important: Please read the Qt Code of Conduct -

[SOLVED]QDoubleValidator and QLocale()

  • Hi!
    I'm trying to use QDoubleValidator for QLineEdit. The proplem is that it let me enter ",", but when I use .To Double() it returns false, cause it can't convert it to double. It can convert it to double only when I use ".", but QDoubleValidator doesn't let me enter it as I said. I decided that the problem is in QLocale and I have to set it for the current system language. I did it, but the situation didn't change. Here is my code.
    @QLineEdit* editor=new QLineEdit(parent);
    QDoubleValidator *validator=new QDoubleValidator(0,std::numeric_limits<double>::max(),2,editor);
    return editor;@

  • Use this one

  • Thanx a lot!It worked=)

Log in to reply