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
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: ...