QT的信息框弹出来以后,往往按钮都是英文的,而这个体验不是很好。我们需要实现的状态如图:
那么如何实现呢?
看到网上说用setbuttontext()方法,这个是不可行的,因为官方文档有这么一句话:
Sets the text of the message box button button to text. Setting the text of a button that is not in the message box is silently ignored.
Use addButton() instead.
这句话的意思说你用这个函数的时候,会被对话框默认忽略,请使用addbutton()函数来代替。
QMessageBox megBox;
megBox.addButton("是",QMessageBox::AcceptRole);
megBox.addButton("否",QMessageBox::RejectRo