Results 1 to 5 of 5

Thread: QLocale/Resource

  1. #1
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QLocale/Resource

    In QResource the example shows the use of QLocale with a resource.

    Qt Code:
    1. <qresource>
    2. <file>cut.jpg</file>
    3. </qresource>
    4. <qresource lang="fr">
    5. <file alias="cut.jpg">cut_fr.jpg</file>
    6. </qresource>
    To copy to clipboard, switch view to plain text mode 

    My question here is if I have a mechanism to change language and adjust QLocale dynamically during program run time will it automagically understand the alias change and adjust for the proper language?

    Bob

  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: QLocale/Resource

    Take a look at that:http://doc.trolltech.com/4.3/i18n.ht...e-translations

    The sample code at the end of the section shows, how to load resources based on current language settings.

    Hope this helps,

    Tom

  3. #3
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLocale/Resource

    Thx DeepDiver but it is a slightly different situation.

    I have just been entrenched in so many other problems I didn't even think I should just create my own working example of it and force QLocale and see what happens....

    Bob

  4. #4
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLocale/Resource

    My problem that I was attempting to solve in the first question was having documentation set in html formatted files and loading them into a QTextEdit depending on what language was in use.

    If I placed in them in a resource file I could then just display them in the QTextEdit appropriately but was unsure of how to access them from resource file and have them displayed.

    I know how to read them in from file and set them but file access times are unacceptable so I figured I could add them as a resource and trade time for size.

    Bob

  5. #5
    Join Date
    Oct 2007
    Posts
    78
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QLocale/Resource

    In case anyone was wondering


    Qt Code:
    1. QFile file(THE_RESOURCE); // This should never fail since its a resource
    2. QByteArray data = file.readAll();
    3. QTextCodec *codec = Qt::codecForHtml(data);
    To copy to clipboard, switch view to plain text mode 

    Bob

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.