Custom QMessageBox Buttons

From Qt Wiki
Revision as of 13:21, 28 June 2015 by Wieland (talk | contribs) (Cleanup)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh


The following code snippet demonstrate how to customize QMessageBox by adding custom text and buttons using method addButton.

Code Snippet

QMessageBox msgBox;
QAbstractButton* pButtonYes = msgBox.addButton(tr("Yeah!"), QMessageBox::YesRole);
msgBox.addButton(tr("Nope"), QMessageBox::NoRole);


if (msgBox.clickedButton()==pButtonYes) {
    //Execute command