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. cant find QLocaleData
Forum Updated to NodeBB v4.3 + New Features

cant find QLocaleData

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 647 Views
  • 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
    nullbuil7
    wrote on last edited by nullbuil7
    #1

    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);
    J.HilkJ 1 Reply Last reply
    0
    • N Offline
      N Offline
      nullbuil7
      wrote on last edited by
      #2

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

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

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

        hpp:

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

        cpp:

        #include "test.h"
        
        test::test()
        {
        }
        
        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;
                }
        }
        
        
        1 Reply Last reply
        0
        • N nullbuil7

          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);
          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @nullbuil7
          you'll finde the struct in the private part of qt source files:
          qlocale_p.h

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


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #5

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

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved