Custom QMessageBox Buttons/bg: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(No difference)

Revision as of 06:47, 24 February 2015


[toc align_right="yes" depth="2"]

Български English

Разнообразни бутони в QMessageBox

Въведение

Приложеният примерен код демонстрира как се добавят бутони с произволен текст в "QMessageBox":http://doc.qt.io/qt-4.8/QMessageBox.html чрез метода "addButton":http://doc.qt.io/qt-4.8/qmessagebox.html#addButton.

Примерен код


QMessageBox msgBox;
msgBox.setText(tr("Потвърждавате ли?"));
QAbstractButton* pButtonYes = msgBox.addButton(tr("Абсолютно."), QMessageBox::YesRole);
msgBox.addButton(tr("Не, не знам."), QMessageBox::NoRole);

msgBox.exec();

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