QMessageBox box;
box.setWindowTitle(QStringLiteral("QMessageBox的例子!!"));
box.setText(QStringLiteral("%1 ||| %2").arg(QStringLiteral("選擇是請選擇左邊的 是 ")).arg(QStringLiteral("選擇否請選擇右邊的 否 ")));
box.setIcon(QMessageBox::Warning);
//添加按鈕
QPushButton* yesBtn = box.addButton(QStringLiteral("是"), QMessageBox::YesRole);
QPushButton* noBtn = box.addButton(QStringLiteral("否"), QMessageBox::NoRole);
box.exec();
if (box.clickedButton() == yesBtn)
{
ui.lineEdit->setText(QStringLiteral("你的選擇是左邊的 是"));
}
else if (box.clickedButton()==noBtn)
{
ui.lineEdit->setText(QStringLiteral("你的選擇是右邊的 否"));
}
