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();

 

你可能感兴趣的:(QInputDialog以及QMessageBox设置按钮为中文)