#include #include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); //Note that the number of decimal digits is 0 ! QValidator* validator = new QDoubleValidator(0., 999., 0, NULL); //Set the locale to German: Note that the character ',' is the //decimal separator and the character '.' is the thousand-separator //in german. This is exactly the opposite to the english or //default C-Locale. validator->setLocale(QLocale::German); QValidator::State state; int pos; //The following line returns "intermediate" state, because the decimal //point is interpreted as the thousand-separator (german locale) state = validator->validate(QString("12.1234"), pos); //The following line returns "intermediate" state, because although //the string is invalid in german-locale, the comma is interpreted as //the thousand-separator in C-locale (which is the fallback) state = validator->validate(QString("12,1234"), pos); //The following line returns "intermediate" state, although //it should return "invalid". Seems to have nothing to do with the //locale, so should be a different/separate problem state = validator->validate(QString("121234"), pos); //Try yourself by uncommenting the following lines //QLineEdit* edit = new QLineEdit(); //edit->setValidator(validator); //edit->show(); //return a.exec(); return 0; }