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("你的选择是右边的 否"));
    }

    

QMessageBox的例子

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2022-03-10
  • 2021-09-27
  • 2022-12-23
  • 2021-09-24
猜你喜欢
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案