[Qt-interest] Query related to Internationalization in loading .qm file at runtime
Hemalatha Venkataswamy
Hemalatha.Venkataswamy at lntinfotech.com
Tue Feb 3 07:33:43 CET 2009
Hi,
Thanks again for your answers.
I capture the event on Language change and tried to change the text of all
the labels/widget I have in the GUI for langauge translation. When I do a
"setText" for the labels, for some labels it reflects and some other
labels on the same dialog box does not get translated.
Please suggest me if you have answers for this. Thanks a lot for your
response.
Thanks With Regards
=================================
Hemalatha,
PES (Communications) , BANGALORE
phone: 91 80 6624 2089
=================================
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do
not use or disseminate the information, notify the sender and delete it
from your system.
<Oliver.Knoll at comit.ch>
Sent by: qt-interest-bounces at trolltech.com
02/02/2009 02:26 PM
To
<qt-interest at trolltech.com>
cc
Subject
Re: [Qt-interest] Query related to Internationalization in loading .qm
file at runtime
Hemalatha Venkataswamy wrote on Friday, January 30, 2009 1:21 PM:
> ... . The language is not affected immediately to the
> widgets. I need to close my application and open the application to
> see the application loaded with a new language.
>
> Could anyone help me in answering, what I need to do to load the
> applciation with .qm file once I select the language from the
> combo-box.
Your widget gets an event: QEvent::LanguageChange (
http://doc.trolltech.com/4.4/qevent.html#Type-enum). You catch this event
through the http://doc.trolltech.com/4.4/qwidget.html#changeEvent method
(which you override in your custom widgets).
Widgets/dialogs designed by Qt Designer do implement this automatically,
so (in theory) you only need to worry about your custom widgets.
Once you receive this event you do something like this (pseudo-code):
MyWidget::MyWidget(QWidget *parent;)
{
...
// create the custom widgets
this->createWidgets(parent);
// set the text (to be translated)
this->updateText();
...
}
// a new *.qm file has been loaded
void MyWidget::changeEvent(QEvent ev)
{
...
if (ev instanceof Qt::QLanguageChangeEvent)
{
this->updateText();
}
...
}
// tr() will make sure that the text is properly translated,
// given the current *.qm file
void MyWidget::updateText()
{
label->setText(tr("Text to be translated");
this->setTitle(tr("Title to be translated");
...
}
There is a Qt example which shows how this works (at least I remember one
from Qt 3 times), but I can't find it right now ;)
Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
______________________________________________________________________
______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090203/bf8b5acc/attachment.html
More information about the Qt-interest-old
mailing list