Custom QMessageBox Buttons: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[Custom QMessageBox Buttons Bulgarian|Български]]
[[Category:snippets]]<br />[[Category:HowTo]]


=Custom QMessageBox Buttons=
[toc align_right=&quot;yes&amp;quot; depth=&quot;2&amp;quot;]


==Introduction==
'''English''' [[Custom_QMessageBox_Buttons_Bulgarian|Български]]


The following code snippet demonstrate how to customize [http://doc.qt.io/qt-4.8/QMessageBox.html QMessageBox] ''[qt.io]'' by adding custom text and buttons using method [http://doc.qt.io/qt-4.8/qmessagebox.html#addButton addButton] ''[qt.io]''.
= Custom QMessageBox Buttons =


==Code Snippet==
== Introduction ==


===Categories:===
The following code snippet demonstrate how to customize &quot;QMessageBox&amp;quot;:http://doc.qt.io/qt-4.8/QMessageBox.html by adding custom text and buttons using method &quot;addButton&amp;quot;:http://doc.qt.io/qt-4.8/qmessagebox.html#addButton.


* [[:Category:HowTo|HowTo]]
== Code Snippet ==
* [[:Category:snippets|snippets]]
 
<code><br />QMessageBox msgBox;<br />msgBox.setText(tr(&quot;Confirm?&quot;));<br />QAbstractButton* pButtonYes = msgBox.addButton(tr(&quot;Yeah!&quot;), QMessageBox::YesRole);<br />msgBox.addButton(tr(&quot;Nope&amp;quot;), QMessageBox::NoRole);
 
msgBox.exec&amp;amp;#40;&amp;#41;;
 
if(msgBox.clickedButton() == pButtonYes)<br />{<br /> //Execute command<br />}

Revision as of 10:14, 24 February 2015


[toc align_right="yes&quot; depth="2&quot;]

English Български

Custom QMessageBox Buttons

Introduction

The following code snippet demonstrate how to customize "QMessageBox&quot;:http://doc.qt.io/qt-4.8/QMessageBox.html by adding custom text and buttons using method "addButton&quot;: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&quot;), QMessageBox::NoRole);

msgBox.exec&amp;#40;&#41;;

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