我试图改变qt对话框的语言以及2个按钮" OK"并且" CLOSE",但我无法这样做,我只能更改短信的语言。
PFB代码:
void updateDiagWidgets() {
QString qstr = QString::fromStdString(MY_String);
QString qyes = QString::fromStdString(MY_String_YES);
QString qno = QString::fromStdString(MY_String_NO);
if(gDiagBox != NULL) {
gDiagBox->setText(qstr);
replaint();
QPushButton* yesBtn = gDiagBox->addButton(qyes, QMessageBox::YesRole);
gDiagBox->addButton(qno, QMessageBox::NoRole);
gDiagBox->setDefaultButton(yesBtn);
}
else {
QMessageBox *msgBox = new QMessageBox(browser);
if(msgBox != NULL) {
DEBUG("updateDiagWidgets Message string is %s\n",MY_String.c_str());
DEBUG("updateDiagWidgets YES string is %s\n",MY_String_YES.c_str());
DEBUG("updateDiagWidgets NO string is %s\n",MY_String_NO.c_str());
msgBox->setWindowTitle("");
msgBox->setText(qstr);
msgBox->setParent(0);
msgBox->setWindowFlags(Qt::Window);
msgBox->setWindowFlags(Qt::BypassWindowManagerHint);
QPushButton* yesBtn = msgBox->addButton(qyes, QMessageBox::YesRole);
msgBox->addButton(qno, QMessageBox::NoRole);
msgBox->setDefaultButton(yesBtn);
gDiagBox = msgBox;
DEBUG("updateDiagWidgets done msgBox updation");
}
else {
DEBUG("updateDiagWidgets Error allocating memory for dialog box");
}
}
}
我能够在上面的代码中单独更改qstr的语言,但我无法更改qyes和qno的语言。 请帮我解决这个问题。
先谢谢。