qtranslator with dynamic labels
-
@Pablo-J.-Rogina https://www.youtube.com/watch?v=In5QH_ZrDJE
but I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after...is it normal? -
@vale88
Hi
Yes that is normal.
Only when you call setText , new text can be used if you loaded a installTranslator
in the mean time.@mrjj a ok, is there a way to solve it?if I try manually it isn't work because there the translator
-
@mrjj a ok, is there a way to solve it?if I try manually it isn't work because there the translator
-
@vale88
Hi
Im not sure what you are doing.
After you loaded a new translator.
You must call setText on all Labels etc. to have them show translated text.@mrjj maybe i understood what you say, but I shoul control the text of the label and then setText inside I think
-
@mrjj maybe i understood what you say, but I shoul control the text of the label and then setText inside I think
@vale88
An alternative to fiddling around changing language at runtime.
You could allow the user to select the language. save the selection to a file
and load that in main. when app starts.
Then to use new language, all you have to do is restart app. -
@Pablo-J.-Rogina https://www.youtube.com/watch?v=In5QH_ZrDJE
but I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after...is it normal?@vale88 said in qtranslator with dynamic labels:
ut I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after
Could you please show both screenshot(s) of the issue and the corresponding snippet of source code?
-
@vale88 said in qtranslator with dynamic labels:
ut I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after
Could you please show both screenshot(s) of the issue and the corresponding snippet of source code?
void MainWindow::on_Traduzione_Inglese_clicked() { qApp->installTranslator(&inglese); ui->Traduzione_Italiano->setDisabled(false); }
there is also change event, if I click the button before that the label is written there is the translation
but if the label is written and then click the button for translation the label is empty:
-
void MainWindow::on_Traduzione_Inglese_clicked() { qApp->installTranslator(&inglese); ui->Traduzione_Italiano->setDisabled(false); }
there is also change event, if I click the button before that the label is written there is the translation
but if the label is written and then click the button for translation the label is empty:
@vale88 void MainWindow::changeEvent(QEvent* event)
{if(event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); if(text=="CONF. CARICATA") ui->Info->setText("CONF. LOADED"); } QWidget::changeEvent(event);
}
in this way it works, but it's manual -
@vale88 said in qtranslator with dynamic labels:
ut I noticed that if I push in button english then labels are written in english because I put tr, but the labels just written in Italian aren't changed in english if I click button after
Could you please show both screenshot(s) of the issue and the corresponding snippet of source code?
@Pablo-J.-Rogina is there a way less manual?
-
@Pablo-J.-Rogina is there a way less manual?
-
@vale88
Hi
Any widget that is not made with UI , must be manually handled.
That is, call its setText again.@mrjj thanks