Results 1 to 4 of 4

Thread: how change language at runtime?

  1. #1
    Join Date
    Oct 2007
    Location
    Italy
    Posts
    172
    Thanks
    39
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how change language at runtime?

    I have a translation problem in my application.
    In the main i'm setting the language in this way:

    Qt Code:
    1. QApplication app ( argc, argv );
    2. QTranslator translator;
    3. translator.load ( "/home/mattia/workspace/myProject/translations/trm_it" );
    4. app.installTranslator ( &translator );
    5. ......
    To copy to clipboard, switch view to plain text mode 

    If i want to set as default language "en" i have to do:
    Qt Code:
    1. translator.load ( "/home/mattia/workspace/myProject/translations/trm_en" );
    To copy to clipboard, switch view to plain text mode 
    and it is correctly loaded, when i'm at runtime i want to change the language and i made a dialog widget to allow the user to insert a language, for example "en", but i don't know how performe the change language at runtime.
    Is it possible do it?
    Thanks

  2. #2
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how change language at runtime?

    Last edited by DeepDiver; 14th November 2007 at 17:00. Reason: Wrong link ....

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how change language at runtime?

    In addition to that, if you want to retranslate a window which is already created (and probably visible), you need to intercept the QEvent::LanguageChange event and retranslate all texts. If you have a Designer created ui, it's enough to call retranslateUi() from the form object.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how change language at runtime?

    J-P Nurmi

Similar Threads

  1. Replies: 8
    Last Post: 15th May 2007, 09:21

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.