Exercise QMessageBox::setInformativeText() in standard dialogs example
Change-Id: Id54a6d93e22fcb6622b434e3766baedb581d6b79 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
826dc56d3a
commit
b2b941823e
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
#define MESSAGE \
|
#define MESSAGE \
|
||||||
Dialog::tr("<p>Message boxes have a caption, a text, " \
|
Dialog::tr("<p>Message boxes have a caption, a text, " \
|
||||||
"and any number of buttons, each with standard or custom texts." \
|
"and any number of buttons, each with standard or custom texts.")
|
||||||
"<p>Click a button to close the message box. Pressing the Esc button " \
|
#define INFORMATIVE_TEXT \
|
||||||
|
Dialog::tr("<p>Click a button to close the message box. Pressing the Escape key " \
|
||||||
"will activate the detected escape button (if any).")
|
"will activate the detected escape button (if any).")
|
||||||
#define MESSAGE_DETAILS \
|
#define MESSAGE_DETAILS \
|
||||||
Dialog::tr("If a message box has detailed text, the user can reveal it " \
|
Dialog::tr("If a message box has detailed text, the user can reveal it " \
|
||||||
@ -413,10 +414,13 @@ void Dialog::setSaveFileName()
|
|||||||
|
|
||||||
void Dialog::criticalMessage()
|
void Dialog::criticalMessage()
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox msgBox(QMessageBox::Critical, tr("QMessageBox::critical()"),
|
||||||
reply = QMessageBox::critical(this, tr("QMessageBox::critical()"),
|
MESSAGE, { }, this);
|
||||||
MESSAGE,
|
msgBox.setInformativeText(INFORMATIVE_TEXT);
|
||||||
QMessageBox::Abort | QMessageBox::Retry | QMessageBox::Ignore);
|
msgBox.addButton(QMessageBox::Abort);
|
||||||
|
msgBox.addButton(QMessageBox::Retry);
|
||||||
|
msgBox.addButton(QMessageBox::Ignore);
|
||||||
|
int reply = msgBox.exec();
|
||||||
if (reply == QMessageBox::Abort)
|
if (reply == QMessageBox::Abort)
|
||||||
criticalLabel->setText(tr("Abort"));
|
criticalLabel->setText(tr("Abort"));
|
||||||
else if (reply == QMessageBox::Retry)
|
else if (reply == QMessageBox::Retry)
|
||||||
@ -427,9 +431,10 @@ void Dialog::criticalMessage()
|
|||||||
|
|
||||||
void Dialog::informationMessage()
|
void Dialog::informationMessage()
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox msgBox(QMessageBox::Information, tr("QMessageBox::information()"),
|
||||||
reply = QMessageBox::information(this, tr("QMessageBox::information()"), MESSAGE);
|
MESSAGE, { }, this);
|
||||||
if (reply == QMessageBox::Ok)
|
msgBox.setInformativeText(INFORMATIVE_TEXT);
|
||||||
|
if (msgBox.exec() == QMessageBox::Ok)
|
||||||
informationLabel->setText(tr("OK"));
|
informationLabel->setText(tr("OK"));
|
||||||
else
|
else
|
||||||
informationLabel->setText(tr("Escape"));
|
informationLabel->setText(tr("Escape"));
|
||||||
@ -437,10 +442,13 @@ void Dialog::informationMessage()
|
|||||||
|
|
||||||
void Dialog::questionMessage()
|
void Dialog::questionMessage()
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton reply;
|
QMessageBox msgBox(QMessageBox::Question, tr("QMessageBox::question()"),
|
||||||
reply = QMessageBox::question(this, tr("QMessageBox::question()"),
|
MESSAGE, { }, this);
|
||||||
MESSAGE,
|
msgBox.setInformativeText(INFORMATIVE_TEXT);
|
||||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
|
msgBox.addButton(QMessageBox::Yes);
|
||||||
|
msgBox.addButton(QMessageBox::No);
|
||||||
|
msgBox.addButton(QMessageBox::Cancel);
|
||||||
|
int reply = msgBox.exec();
|
||||||
if (reply == QMessageBox::Yes)
|
if (reply == QMessageBox::Yes)
|
||||||
questionLabel->setText(tr("Yes"));
|
questionLabel->setText(tr("Yes"));
|
||||||
else if (reply == QMessageBox::No)
|
else if (reply == QMessageBox::No)
|
||||||
@ -453,6 +461,7 @@ void Dialog::warningMessage()
|
|||||||
{
|
{
|
||||||
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
|
QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"),
|
||||||
MESSAGE, { }, this);
|
MESSAGE, { }, this);
|
||||||
|
msgBox.setInformativeText(INFORMATIVE_TEXT);
|
||||||
msgBox.setDetailedText(MESSAGE_DETAILS);
|
msgBox.setDetailedText(MESSAGE_DETAILS);
|
||||||
msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
|
msgBox.addButton(tr("Save &Again"), QMessageBox::AcceptRole);
|
||||||
msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
|
msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole);
|
||||||
|
Loading…
Reference in New Issue
Block a user