> ## Content Index
> Fetch the complete content index at: https://www.smallstepsystems.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# New in Qt 5.10: Dynamic Language Change in QML
- URL: https://www.smallstepsystems.com/new-in-qt-5-10-dynamic-language-change-in-qml/
- Published: 2017-11-12T11:59:12.000Z
- Updated: 2026-01-25T15:49:59.000Z
- Author: Burkhard Stubert

My favourite new feature in Qt 5.10 is the inconspicuous function `QmlEngine::retranslate()`. Finally, seven years after QML's birth, there is a Qt way to change the language of your application at runtime. There is no need for workarounds any more (see [How to do dynamic translation in QML](https://wiki.qt.io/How%5Fto%5Fdo%5Fdynamic%5Ftranslation%5Fin%5FQML?ref=smallstepsystems.com) for the standard workaround).

I wrote a simple application demonstrating the new feature. If we click the British (German) flag on the right-hand side, the language of the labels on the left-hand side is changed accordingly.

![](https://storage.ghost.io/c/c7/ee/c7ee1cf5-b86f-491b-aab7-20ad081598e1/content/images/2025/11/dynamiclanguageswitching.png)

How does the dynamic language change work?

The workaround required us to add a global QML property to each call of the `qsTr()` function:

text: qsTr("Hello") + rootItem.emptyString

When the language changes, the notification signal of the global property `rootItem.emptyString` is emitted. Hence, every binding with this global property is reevaluated and every text string is translated.

The function `QQmlEngine::retranslate` introduced in Qt 5.10 simply reevaluates all property bindings. This includes all the bindings with a call to `qsTr()` on the right-hand side. In a future version, it will only reevaluate all bindings containing `qsTr()`. The new function automates what we had to emulate manually with the global property.

We can drop the global property in the bindings of translatable texts and simply write

text: qsTr("Hello")

The function for switching the language looks as follows (with error handling removed).

void Settings::switchToLanguage(const QString &language) { if (!m\_translator.isEmpty()) QCoreApplication::removeTranslator(&m\_translator); m\_translator.load(QStringLiteral(":/language\_") + language); QCoreApplication::installTranslator(&m\_translator); m\_engine->retranslate(); }

If another translator has been loaded before, this translator is removed. Then, the new translator is loaded and installed. Finally, the call to `m_engine->retranslate()` reevaluates all the property bindings containing calls to `qsTr()`. This makes for simpler and more robust QML code than before.