[Qt-interest] Antwort: Re: How to change the language at run time in the Application
Markus Franke
Franke.M at sebakmt.com
Tue May 19 16:20:47 CEST 2009
After installing a new translator via qApp->installTranslator() you need
to emit some kind of a languageChanged signal. Then you connect this
signal to all your GUI elements which need to be changed during runtime
and in their respective slots you do an update.
Hope this helps,
Mit freundlichen Grüßen / Best regards
Markus Franke
Entwicklung/ Development
SebaKMT
Hagenuk KMT Kabelmesstechnik GmbH
Röderaue 41
01471 Radeburg / Germany
Reg.Gericht (01067 Dresden) HRB 12567
Geschäftsf.: Dr. Max Iann
Phone +49 (0)35208 84 29142
Fax +49 (0)35208 84 29249
e-mail: franke.m at sebaKMT.com
web: http//www.sebaKMT.com
qt-interest-bounces at trolltech.com schrieb am 19.05.2009 15:56:04:
> 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.
> ___________________________________________________________
>
>
> _______________________________________________
> 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/20090519/3803ec26/attachment.html
More information about the Qt-interest-old
mailing list