PDA

View Full Version : QLocale/Resource



coderbob
21st November 2007, 16:33
In QResource the example shows the use of QLocale with a resource.



<qresource>
<file>cut.jpg</file>
</qresource>
<qresource lang="fr">
<file alias="cut.jpg">cut_fr.jpg</file>
</qresource>


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

DeepDiver
21st November 2007, 16:36
Take a look at that:http://doc.trolltech.com/4.3/i18n.html#produce-translations

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

Hope this helps,

Tom

coderbob
21st November 2007, 18:45
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

coderbob
21st November 2007, 19:08
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

coderbob
21st November 2007, 20:51
In case anyone was wondering




QFile file(THE_RESOURCE); // This should never fail since its a resource
QByteArray data = file.readAll();
QTextCodec *codec = Qt::codecForHtml(data);


Bob