You are not logged in.

robert456

Beginner

  • "robert456" is male
  • "robert456" started this thread

Posts: 13

Occupation: Student

  • Send private message

1

Wednesday, October 13th 2010, 5:00pm

multi-language application

Hi everybody,
I'm working on an application that use 2 laguages french and english.
I can install and change the language of the application without any probleme.
I'm using this code in the main:

QTranslator translator;
translator.load(ln);//ln is a string containing language file name
app.installTranslator(&translator);



In my application, i'm using QMessageBox with the 2 bouttons YES and NO.
My probleme is that this 2 bouttons are always in english even if I use the french language.
How can I change the language of these bouttons in fonction with the application language??


Thanks for your answers ^^

2

Wednesday, October 13th 2010, 11:10pm

If you use the default message box's buttons, they are always handled by the OS, so their language is the OS's language. You need to add custom buttons, check this example from the docs:

Source code

1
2
3
4
5
6
7
8
9
10
 QMessageBox msgBox;
 QPushButton *connectButton = msgBox.addButton(tr("Connect"), QMessageBox::ActionRole);
 QPushButton *abortButton = msgBox.addButton(QMessageBox::Abort);

 msgBox.exec();

 if (msgBox.clickedButton() == connectButton) {
     // connect
 } else if (msgBox.clickedButton() == abortButton) {
     // abort

3

Thursday, October 14th 2010, 7:16pm

I have seen that multi-language example involving language files but there is no example involving multiple help files (but only involving one help file)

robert456

Beginner

  • "robert456" is male
  • "robert456" started this thread

Posts: 13

Occupation: Student

  • Send private message

4

Friday, October 15th 2010, 2:43pm

Thanks for the answers.
But actually, I'm using the static fonction QMessageBox::question because it's easy to handle and to manipulate.
So, is there a solution with the static fonction??