QMenu And QSqlQueryModel translation problem !
-
Hi ~ I am using Qt 5.15.2 , in my test software everything being translated successfully! except QMenu And QSqlTableModel
This is an example how i am using bothFirst QMenu:
mainsettingsMenu=new QMenu(this); custom1=new QAction(QObject::tr("م 1"),this); custom2=new QAction(tr("م 2"),this); custom3=new QAction(tr("م 3"),this); custom4=new QAction(tr("م 4"),this); custom5=new QAction(tr("م 5"),this); mainsettingsMenu->addAction(custom1); mainsettingsMenu->addAction(custom2); mainsettingsMenu->addAction(custom3); mainsettingsMenu->addAction(custom4); mainsettingsMenu->addAction(custom5); ); ui->settingsbtn->setMenu(mainsettingsMenu);
Second QSqlTableModel :
test=new QSqlTableModel(this); test->setTable("testTable"); test->select(); test->setFilter(filter); ui->tableView->setModel(test); test->setHeaderData(1, Qt::Horizontal, tr("م 1")); test->setHeaderData(2, Qt::Horizontal, tr("م 2")); test->setHeaderData(3, Qt::Horizontal, tr("م 3")); test->setHeaderData(4, Qt::Horizontal, tr("م 4")); test->setHeaderData(5, Qt::Horizontal, tr("م 5")); test->setHeaderData(6, Qt::Horizontal, tr("م 6"));
i am using those to reload translations ...
QApplication::installTranslator(&translator); // qApp->installTranslator(&translator); ui->retranslateUi(this);
By The way i am translating from Unicode language to French ... everything works , except those two ...
-
Christian Ehrlicher Lifetime Qt Championreplied to Proton Phoenix on 27 Feb 2023, 18:32 last edited by Christian Ehrlicher
retranslateUi() can only change the texts on the widgets the ui file created. How should it e.g. access a QSqlTableModel (and know what text you've set somewhere)? You have to set the new texts by yourself.
-
@Christian-Ehrlicher said in QMenu And QSqlQueryModel translation problem !:
retranslateUi() can only change the texts on the widgets the ui file created. How should it e.g. access a QSqlTableModel (and know what text you've set somehwere)? You have to set the new texts by yourself.
Thank you bro ... when i saw QtLinguist gives the power to edit those texts there .. i thought Qt Can Handle it somehow ...
Thank you so much ^^ <3 -
-
@Proton-Phoenix Hi,
One way to handle it is to act on the
QEvent::LanguageChange
event so you can trigger the re-translation of your UI. -
@SGaist said in QMenu And QSqlQueryModel translation problem !:
QEvent::LanguageChange
@SGaist Hi bro <3
i didn't know about QEvent::LanguageChange before really thank you, i will check it <3
5/5