Solved QT_TRANSLATE_NOOP translation not triggered?
-
Hi,
I'm having few static variables defined in an Object using QT_TRANSLATE_NOOP.in header: static const char *sFolderMonitoringName; static const char *sQuickJobName; in cpp: const char *NgPost::sFolderMonitoringName = QT_TRANSLATE_NOOP("NgPost", "Auto Posting"); const char *NgPost::sQuickJobName = QT_TRANSLATE_NOOP("NgPost", "Quick Post");
So then in my MainWindow::changeEvent(QEvent *event) that is triggered each time a translator is installed, I'm trying to use those static members to some texts but it's not working...
Any idea why?void MainWindow::changeEvent(QEvent *event) { if(event) { QTabBar *tabBar = _ui->postTabWidget->tabBar(); switch(event->type()) { // this event is send if a translator is loaded case QEvent::LanguageChange: _ui->retranslateUi(this); tabBar->setTabText(0, tr(_ngPost->sQuickJobName)); tabBar->setTabText(1, tr(_ngPost->sFolderMonitoringName)); ...
Of course their text are in the ts file, and I've provided a translation in other languages.
If I were not using those static member variable but somethink liketabBar->setTabText(0, tr("my title"));
It is working...
I'm using QT_TRANSLATE_NOOP in other places and it's working perfectly.
Am I missing something?
Cheers -
@mbruel said in QT_TRANSLATE_NOOP translation not triggered?:
Am I missing something?
The namespace is wrong, you're calling tr from the MainWindow.
-
oh it has to be on the same namespace... I thought it would pick it up from the object being used...
Cheers man, I just did some accessors and it's working perfectly!