cant find QLocaleData

  • I'm overloading the QValidator class and don't know where to find QLocaleData definition (according to qt source file it's there). <QLocale> or any other #include file i could think of doesn't have it .
    I need it for this line to work:

    qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok);

  • after searching more I'm not even sure there is a QLocaleData It's just in qt source files. I'll keep digging...

  • this is as far as i got to override QIntValidator, Still don't know what to do with QLocaleData::


    #ifndef TEST_H
    #define TEST_H
    #include <QValidator>
    class test : public QIntValidator
        using QIntValidator::QIntValidator;
        virtual State validate(QString &, int &) const override;
        int b;
        int t;
    #endif // TEST_H


    #include "test.h"
    QValidator::State test::validate(QString & input, int &) const
            bool ok;
            QByteArray buff;
            qlonglong entered = QLocaleData::bytearrayToLongLong(buff.constData(), 10, &ok);
            if (entered >= b && entered <= t) {
                locale().toInt(input, &ok);
                return ok ? Acceptable : Invalid;

  • Moderators

    you'll finde the struct in the private part of qt source files:

    Those can and will change without notice so use it on your own caution

  • Lifetime Qt Champion

    Why not simply calling the base implementation and doing the check afterwards?
    Apart from this you're missing a return value.

Log in to reply