<< to CrossControl homepage

Support & Service Center

Usage of several languages / translations in Qt

Printer-friendly versionPrinter-friendly versionPDF versionPDF version

In order to use several languages, the language files have to be added to the project and transfered to the target while deploying. To do this, add the following to your project file (.pro):

TRANSLATIONS += lang_de.ts \
tsFile.files = *.qm
tsFile.path = /opt/app-folder
INSTALLS += tsFile

In your application, add the following to the constructor of your Application:

Application::Application(QWidget *parent) :
    ui(new Ui::Application)

    QTranslator *translator = new QTranslator();
    if(translator->load(QString("lang_de"), qApp->applicationDirPath())) {

        qDebug() << "Translation file loaded!\n\n";


The translator-files must not be installed in the main.cpp. The language files can be edited in the QtLinguist tool, which can be installed using

sudo apt-get install qt4-dev-tools

Click here for more information about multi-language support in Qt