Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-40778

setNumericMode() looses its property every time you change locale in QCollator

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.4.0 Beta
    • 5.3.1
    • None
    • Tested on Windows

    Description

      Every time you set the locale in QCollator setNumericMode needs to be reset.

      #include <QApplication>
      #include <QCollator>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
           QCollator collator;
          collator.setNumericMode( true );
          qDebug() << QLocale::system();
          qDebug() << collator.locale();
      
          collator.setLocale( QLocale::system()); 
          qDebug() << collator.locale();
          collator.setLocale( collator.locale() ); 
          qDebug() << collator.locale();
          collator.setLocale( QLocale() );
          qDebug() << collator.locale();
          //collator.setNumericMode( true ); // uncomment it to compare in natural way otherwise it will do it lexically
          qDebug()<<collator.compare( "Test 8", "Test 79" );
      
          return 0;
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            laknoll Lars Knoll
            qtcomsupport Qt Support
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes