[Interest] QMessageBox - Accept/Reject

Igor Mironchik igor.mironchik at gmail.com
Fri Apr 28 21:30:39 CEST 2017



28.04.2017 21:23, Igor Mironchik пишет:
>
> Hello,
>
> Following code:
>
> QMessageBoxdlg(this);
>
> dlg.setText(tr("Wouldyouliketosaveconfiguration?"));
> QPushButton*btn=dlg.addButton(tr("Yes"),QMessageBox::AcceptRole);
> dlg.addButton(tr("No"),QMessageBox::RejectRole);
> dlg.setDefaultButton(btn);
> intret=dlg.exec();
> qDebug()<<ret;
>
> prints 0 when I press "Yes" button and 1 when I press "No" button. That is inverted
> with QDialog::DialogCode.
>
> Is it a known bug?

It's not a bug. Just interesting why was made so decision?! 
QDialog::Accepted = 1 whereas QMessageBox::AcceptRole = 0. Interesting...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170428/b19609c2/attachment.html>


More information about the Interest mailing list