Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Application Development with Qt Creator - Second Edition
  • Toc
  • feedback
Application Development with Qt Creator - Second Edition

Application Development with Qt Creator - Second Edition

4 (25)
close
Application Development with Qt Creator - Second Edition

Application Development with Qt Creator - Second Edition

4 (25)

Overview of this book

This book is great for developers who are new to Qt and Qt Creator and who are interested in harnessing the power of Qt for cross-platform development. If you have basic experience programming in C++, you have what it takes to create engaging cross-platform applications using Qt and Qt Creator!
Table of Contents (15 chapters)
close
14
Index

Including localized strings in your application


In order to supply translated strings to the tr and qsTr functions in your application, your application needs to include a QTranslator object to read the .qm files and replace the strings provided to tr and qsTr with their translated counterparts. We can do this in your main entry point function, as follows:

QApplication a(argc, argv);
QTranslator translator;
bool result = translator.load("QtLinguistExample-epo.qm");
a.installTranslator(&translator);

    // Other window setup stuff goes here
    
return a.exec();

This code allocates a QTranslator object and loads the indicated translation file into the translator before installing it into the QApplication object. In this example, we're hardcoding the language in order to localize to Esperanto.

Note that if you want to support the locale as picked by the system, you might choose to do it this way:

QString locale = QLocale::system().name();
QTranslator translator;
translator.load(QString("QtLinguistExample...
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete