I am using Qt linguist to translate my application (ui file and the rest of the code). Everything goes alright , the problem is all translations (in ui) work fine except an element added not from designer, here is my code to further explain :
tableWidget = new MyDropTableWidget(ui->verticalLayoutWidget_2);
if (tableWidget->columnCount() < 1)
tableWidget->setColumnCount(1);
tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("My non translated text"))); if (tableWidget->rowCount() < 21)
tableWidget->setRowCount(21);
...
ui->verticalLayout_2->addWidget(tableWidget);
...
in main file:
QTranslator Translator ;
qDebug()<<"Translator->load( lang)"<< Translator.load(":/"+language);
app.installTranslator( &Translator );
in mainwindow constructor:
ui->retranslateUi(this);
all texts in ui are translated fine , only “My non translated text” was not. *.ts file are ok (“My non translated text” was detected and checked) , .qm file are well placed, I rebuild re lupdate re lrelease my application but in vain: when executing my application, all texts are translated expect “My non translated text” still in the source language.
Any help will be appreciated.
↧