Disambiguating identical texts
If there are identical texts, the default behavior is to treat them as the texts with the same meaning. This could effectively save translators from translating the same texts. Meanwhile, this doesn't hold true all the time. For instance, the word open
can be used as a noun or an adjective, which may be different words in other languages. Thankfully, it's possible and easy to disambiguate identical texts in Qt.
Now, let's add a PushButton
and openButton
between transButton
and nonTransLabel
. Use Open
as its text, and then edit mainwindow.h
. Add a new private slot named onOpenButtonClicked()
, which is used to handle the event when openButton
gets clicked. The relevant source file, mainwindow.cpp
, is pasted as follows:
#include <QMessageBox> #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); connect(ui->openButton, &QPushButton:...