Custom QMessageBox Buttons: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
[[Category:snippets]] | [[Category:snippets]] | ||
[[Category:HowTo]] | |||
[toc align_right= | [toc align_right="yes" depth="2"] | ||
'''English''' [[Custom_QMessageBox_Buttons_Bulgarian|Български]] | '''English''' [[Custom_QMessageBox_Buttons_Bulgarian|Български]] | ||
Line 9: | Line 10: | ||
== Introduction == | == Introduction == | ||
The following code snippet demonstrate how to customize | The following code snippet demonstrate how to customize "QMessageBox":http://doc.qt.io/qt-4.8/QMessageBox.html by adding custom text and buttons using method "addButton":http://doc.qt.io/qt-4.8/qmessagebox.html#addButton. | ||
== Code Snippet == | == Code Snippet == | ||
<code> | <code> | ||
QMessageBox msgBox; | |||
msgBox.setText(tr("Confirm?")); | |||
QAbstractButton* pButtonYes = msgBox.addButton(tr("Yeah!"), QMessageBox::YesRole); | |||
msgBox.addButton(tr("Nope"), QMessageBox::NoRole); | |||
msgBox.exec | msgBox.exec(); | ||
if(msgBox.clickedButton() == pButtonYes) | if(msgBox.clickedButton() == pButtonYes) | ||
{ | |||
//Execute command | |||
} |
Revision as of 10:35, 25 February 2015
[toc align_right="yes" depth="2"]
English Български
Custom QMessageBox Buttons
Introduction
The following code snippet demonstrate how to customize "QMessageBox":http://doc.qt.io/qt-4.8/QMessageBox.html by adding custom text and buttons using method "addButton":http://doc.qt.io/qt-4.8/qmessagebox.html#addButton.
Code Snippet
QMessageBox msgBox;
msgBox.setText(tr("Confirm?"));
QAbstractButton* pButtonYes = msgBox.addButton(tr("Yeah!"), QMessageBox::YesRole);
msgBox.addButton(tr("Nope"), QMessageBox::NoRole);
msgBox.exec();
if(msgBox.clickedButton() == pButtonYes)
{
//Execute command
}