Reader small image

You're reading from  Cross-Platform Development with Qt 6 and Modern C++

Product typeBook
Published inJun 2021
PublisherPackt
ISBN-139781800204584
Edition1st Edition
Tools
Right arrow
Author (1)
Nibedit Dey
Nibedit Dey
author image
Nibedit Dey

Nibedit Dey is a software engineer turned serial entrepreneur with over a decade of experience in building complex software-based products with amazing user interfaces. Before starting his entrepreneurial journey, he worked for Larsen and Toubro and Tektronix in different R&D roles. He holds a bachelor's degree in biomedical engineering and a master's degree in digital design and embedded systems. Specializing in Qt and embedded technologies, his current role involves end-to-end ownership of products right from architecture to delivery. Currently, he manages two technology-driven product startups named ibrum technologies and AIDIA Health. He is a tech-savvy developer who is passionate about embracing new technologies.
Read more about Nibedit Dey

Right arrow

Writing source code for translation

In this section, we will discuss how to mark strings as translatable strings and how to use the tools provided by Qt. Wherever your application uses a quoted string that is visible to the user, make sure the QCoreApplication::translate() method processes it. To do this, simply use the tr() method to mark the strings as translatable that are meant for display purposes. This feature is used to show which text strings are translatable inside your C++ source files.

For example, if you want to use a QLabel to show text on a user interface, then embed the text inside the tr() method as follows:

QLabel *label = new QLabel(tr("Welcome"));

The class name is the translation context for the QObject and its derived classes. To override the context, QObject-derived classes must use the Q_OBJECT macro in their class definition. This macro sets the context for the derived classes.

Qt provides several convenience macros and methods for internationalization...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Cross-Platform Development with Qt 6 and Modern C++
Published in: Jun 2021Publisher: PacktISBN-13: 9781800204584

Author (1)

author image
Nibedit Dey

Nibedit Dey is a software engineer turned serial entrepreneur with over a decade of experience in building complex software-based products with amazing user interfaces. Before starting his entrepreneurial journey, he worked for Larsen and Toubro and Tektronix in different R&D roles. He holds a bachelor's degree in biomedical engineering and a master's degree in digital design and embedded systems. Specializing in Qt and embedded technologies, his current role involves end-to-end ownership of products right from architecture to delivery. Currently, he manages two technology-driven product startups named ibrum technologies and AIDIA Health. He is a tech-savvy developer who is passionate about embracing new technologies.
Read more about Nibedit Dey