Hi,

Thanks for your mail.

When the language changes, have the LocaleUpdater emit the
localeChanged() signal. Does it mean we need to implement the event() function 
in LocaleUpdater
to catch the QEvent::Localechange event and emit localeChanged() signal?

Best Regards,
Ramakanth

-----Original Message-----
From: 
interest-bounces+ramakanthreddy_kesireddy=mahindrasatyam....@qt-project.org 
[mailto:interest-bounces+ramakanthreddy_kesireddy=mahindrasatyam....@qt-project.org]
 On Behalf Of Bo Thorsen
Sent: 01 October 2013 13:19
To: interest@qt-project.org
Subject: Re: [Interest] Dynamic translation using Qt Quick 2.x in Qt5.1.1

Den 01-10-2013 07:36, Ramakanthreddy Kesireddy skrev:
> Hi,
>
> I would like to know if it is possible to update the text dynamically
>
> for any locale change in QtQuick(QML) using Qt5.1.1.

No, not directly. But there are a couple of things you can do instead.

The key in both my solutions is to have a single C++ object with a property 
registered to QML:

   class LocaleUpdater : public QObject {
     Q_OBJECT
     Q_PROPERTY(QString localeChange READ localeChange
       NOTIFY localeChanged)
   ...
     QString localeChange() const { return QString(); }
   };

Export this to the QML:

   LocaleUpdater updater;
   qml.rootContext()->setContextProperty("localeUpdater", &updater);

When the language changes, have the LocaleUpdater emit the
localeChanged() signal. You can now do one of two things:

1) Use the text updater string directly:

   someObject.text: qsTr("Foo") + localeUpdater.localeChange

2) Catch the emitted signal and set all strings

   Connections {
     target: localeUpdater
     onLocaleChange: {
       someObject.text = qsTr("Foo")
     }
   }

I hope this helps.

Bo.

--
Bo Thorsen, European Qt Manager, ICS
Integrated Computer Solutions. Delivering World-Class Applications 
http://ics.com/services _______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

________________________________

DISCLAIMER:
This email (including any attachments) is intended for the sole use of the 
intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE 
COMPANY INFORMATION. Any review or reliance by others or copying or 
distribution or forwarding of any or all of the contents in this message is 
STRICTLY PROHIBITED. If you are not the intended recipient, please contact the 
sender by email and delete all copies; your cooperation in this regard is 
appreciated.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to