QInputDialog以及QMessageBox设置按钮为中文

QInputDialog

QInputDialog* inputDialog=new QInputDialog(this);
inputDialog->setWindowTitle("提示");
inputDialog->setLabelText("姓名:");
inputDialog->setOkButtonText("确定");
inputDialog->setCancelButtonText("取消");
bool ok;
if(inputDialog->exec()==QDialog::Accepted){
	ok=true;
}else{
	ok=false;
}
QString text=inputDialog->textValue();

QMessageBox

QMessageBox box(QMessageBox::Warning,"警告","信息填写错误");
box.setStandardButtons (QMessageBox::Ok|QMessageBox::Cancel);
box.setButtonText (QMessageBox::Ok,QString("确 定"));
box.setButtonText (QMessageBox::Cancel,QString("取 消"));
box.exec();

 


版权声明:本文为qq_36284984原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。