×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Question How to change locale?

    I'm trying to change the the locale for my app, in order to show correctly the date and to have consistent decimal symbol. I've tried to use QLocale::setDefault(QLocale::English, QLocale::UnitedStates) but I get "no matching function" error. What am I missing? Or is there a better way to do it?

    Thanks

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to change locale?

    http://doc.qt.nokia.com/4.6/qlocale.html#setDefault
    void QLocale::setDefault ( const QLocale & locale )

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to change locale?

    Quote Originally Posted by divanov View Post
    http://doc.qt.nokia.com/4.6/qlocale.html#setDefault
    void QLocale::setDefault ( const QLocale & locale )
    Yes, that is exactly what I'm trying to use, but I get an error. I must be missing something.

  4. #4
    Registered User
    Join Date
    Jun 2010
    Posts
    10

    Re: How to change locale?

    This is probably because you are passing enums, while the function expects a locale object.

    This should work (although I haven't tested it):
    Code:
    QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
    Good luck with you app!

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    272

    Re: How to change locale?

    Quote Originally Posted by sdragly View Post
    This is probably because you are passing enums, while the function expects a locale object.

    This should work (although I haven't tested it):
    Code:
    QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));
    Good luck with you app!
    Thanks, it works without errors now.

    The only problem is that it doesn't seem to affect the language format of the date. It does how ever change the decimal symbol.

  6. #6
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: How to change locale?

    It works fine for me
    Code:
    #include <QtCore>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication a(argc, argv);
    
        for (int i = 1 ; i < QLocale::LastLanguage; i++) {
            QLocale::setDefault(QLocale((QLocale::Language)i));
            QLocale newLocale;
            qDebug() << newLocale.name()
                     << newLocale.dateFormat();
        }
    }

Similar Threads

  1. Replies: 10
    Last Post: 2010-10-29, 08:02
  2. rename application
    By sunny_singh in forum Symbian
    Replies: 6
    Last Post: 2009-05-18, 09:57
  3. Is it possible to change theme programmatically on S60 3rd addition?
    By jain_0882 in forum Symbian Media (Closed)
    Replies: 6
    Last Post: 2009-03-10, 16:16
  4. Replies: 0
    Last Post: 2008-01-10, 13:57

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •