Translating Qt Widgets applications

First, let's create a new Qt Widget project, whose name is Internationalization. Then, edit mainwindow.ui in the Design mode.

  1. As usual, remove the status bar, menu bar, and tool bar.
  2. Add Label into centralWidget and change its object name to nonTransLabel. Then, change its text to This is a non-translatable label and uncheck translatable under text in Property Editor.
  3. Drag a Push Button just beneath nonTransLabel with transButton as its object name. Change its text to This is a translatable button.
  4. Change Lay out to Lay Out Vertically in MainWindow.
  5. Resize the frame to a comfortable size.

Go back to editing the Internationalization.pro project file in the Edit mode. Add a line indicating the translation source file, ...

Get Qt 5 Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.