Results 1 to 3 of 3

Thread: Change QLocale

  1. #1
    Join Date
    Oct 2013
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Change QLocale

    How can I change the QLocale in my application many times? I need to change the language of QCalendar many times, so I need to change the locale.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Change QLocale

    You can use QLocale::setDefault.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Oct 2013
    Posts
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Change QLocale

    I have try that already, but it doesn't work well.[CODE]void QtFrameless::changeLanguage(int i)
    {
    if(i == 1)
    {
    tran->load(QString("./qtframeless_en.qm"));
    languageFlag = 1; //æ›´æ”¹æ—¶é—´æ ¼å¼ç”¨ç „
    QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));

    QDate d;
    ui.dateEdit = new QDateEdit(d.currentDate());
    ui.dateEdit_2 = new QDateEdit(d.currentDate());
    }
    else if(i == 0)
    {
    tran->load(QString("./qtframeless_zh.qm"));
    languageFlag = 0;

    QLocale::setDefault(QLocale(QLocale::Chinese, QLocale::China));
    QDate d;
    ui.dateEdit = new QDateEdit(d.currentDate());
    ui.dateEdit_2 = new QDateEdit(d.currentDate());
    }[CODE]

Similar Threads

  1. QMap sorting according to QLocale
    By sedi in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2013, 20:12
  2. edit QLocale
    By kito in forum Qt Programming
    Replies: 3
    Last Post: 7th January 2013, 13:08
  3. QLocale and date
    By jiveaxe in forum Newbie
    Replies: 2
    Last Post: 21st May 2012, 09:37
  4. QLocale/Resource
    By coderbob in forum Newbie
    Replies: 4
    Last Post: 21st November 2007, 20:51
  5. QLocale confusion :(
    By gri in forum Qt Programming
    Replies: 6
    Last Post: 15th June 2007, 13:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.