[Qt-interest] How to change the language at run time in the Application
Santhosh Y
santhosh at softjin.com
Tue May 19 15:56:04 CEST 2009
Hi Thomas,
Thanks for the information. I have gone through it, but I am having a
doubt that how
we will change a particular string in to a different language at run time.
Following is the example I am trying for. qMainwindow has some action
"Language 1"
When the user clicks it in the run time, I want to change Qpushbutton
text to the "Language 1" equivalent.
#My project file::
SOURCES = main.cpp
TRANSLATIONS = hellotr_lan1.ts
MainWindow :: MainWindow ()
{
QMenuBar* b = menuBar ();
QMenu* m = b->addMenu ("Languages");
myLan1 = new QAction(QAction::tr("Language 1", m));
connect(myLan1, SIGNAL(triggered () ), this, SLOT (Lang1() ));
m->addAction (myLan1);
// button
QPushButton* hello = new QPushButton(QPushButton::tr("Hello world!"));
setCentralWidget (hello);
}
void
MainWindow::Lang1 ()
{
QTranslator t;
t.load("hellotr_lan1");
qApp->installTranslator(&t);
}
Please help in this regard
Santhosh.
Thomas Dähling wrote:
> You'll have to re-implement the changeEvent() function.
>
> See also:
>
> http://wiki.qtcentre.org/index.php?title=Dynamic_translation_in_Qt4_applications
>
> /Thomas
>
> Am Dienstag, den 19.05.2009, 18:11 +0530 schrieb Santhosh Y:
>
>> Hi,
>>
>> How to change dynamically laguage of QAction/QPushButton items
>>
>> I have gone through the example linguist/hellotr/main.cpp present in
>> Assistant.
>> I am able to understand the same and I able to run the example given here.
>>
>> My requirement is that, I should be able to change the language at run
>> time in a application.
>>
>>
>
>
--
----------------------------------------------------
Y Santhosh Kumar
Senior Software Engineer
SoftJin Technologies Private Limited
Unit No. 102, Mobius Tower,
I Floor, SJR I - Park,
EPIP, White Field,
Bangalore - 560066, India
U : www.softjin.com
E : santhosh at softjin.com
T : +91-80-41779999
M : +91-9740535265
----------------------------------------------------
Business Disclaimer
____________________________________________________________
This e-mail message and any files transmitted with it are intended solely
for the use of the individual or entity to which they are addressed. It
may contain confidential, proprietary or legally privileged information.
If you are not the intended recipient please be advised that you have
received this message in error and any use is strictly prohibited. Please
immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender by return mail. You must not,
directly or indirectly, use, disclose, distribute, print, or copy any part of
this message if you are not the intended recipient.
___________________________________________________________
More information about the Qt-interest-old
mailing list