Important: Please read the Qt Code of Conduct -

[resolved] UIC command line tool and the -tr parameter

  • When *.ui files are saved, they generate an *.h file which defines and implements a translation method "retranslateui()" which uses a QApplication::translate call where the context for the translation equals the UI class name.

    I need to be able to override that and put in my own custom context name.

    The reason if you must know is that we have a non-QT legacy translation tables, with 14 languages. I built a tool that translates those strings into a *.TS file. The problem is, there IS NO CONTEXT, it's just a flat list of strings, so my tool forces one context for my entire application. The automatic generation of translate method calls where the context = the UI class name fails my ui translation.

    I found that the UIC command line utility, creating this *.h file from the *.ui file has a parameter to define a different translation method. I can use this to route to my own translation method that'll add on the single context. My problem is that I can't find out how to change the UIC call from qmake to include this parameter with a custom value.

  • okay, just added @"QMAKE_UIC += -tr TRAN_UI"@ to my project file with a name where TRAN_UI is my macro to handle translation with my fixed context. Works nicely.

Log in to reply