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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.3.1
    • Fix Version/s: 5.4.0 Beta
    • Labels:
      None
    • Environment:
      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

            • Assignee:
              laknoll Lars Knoll
              Reporter:
              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