Qt 4.8
qmessagebox.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <QtGui/qmessagebox.h>
43 
44 #ifndef QT_NO_MESSAGEBOX
45 
46 #include <QtGui/qdialogbuttonbox.h>
47 #include "private/qlabel_p.h"
48 #include "private/qapplication_p.h"
49 #include <QtCore/qlist.h>
50 #include <QtCore/qdebug.h>
51 #include <QtGui/qstyle.h>
52 #include <QtGui/qstyleoption.h>
53 #include <QtGui/qgridlayout.h>
54 #include <QtGui/qdesktopwidget.h>
55 #include <QtGui/qpushbutton.h>
56 #include <QtGui/qaccessible.h>
57 #include <QtGui/qicon.h>
58 #include <QtGui/qtextdocument.h>
59 #include <QtGui/qapplication.h>
60 #include <QtGui/qtextedit.h>
61 #include <QtGui/qtextbrowser.h>
62 #include <QtGui/qmenu.h>
63 #include "qdialog_p.h"
64 #include <QtGui/qfont.h>
65 #include <QtGui/qfontmetrics.h>
66 #include <QtGui/qclipboard.h>
67 
68 #ifndef QT_NO_STYLE_S60
69 #include <qs60style.h>
70 #endif
71 
72 #ifdef Q_WS_WINCE
73 extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
74 extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
75 extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
76 
77 #include "qguifunctions_wince.h"
78 #endif
79 
81 
82 enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
84  NewButtonMask = 0xFFFFFC00 };
85 
87 #ifndef QT_NO_TEXTEDIT
89 {
90 public:
91  class TextEdit : public QTextEdit
92  {
93  public:
96  {
97 #ifndef QT_NO_CONTEXTMENU
100  menu->popup(e->globalPos());
101 #else
102  Q_UNUSED(e);
103 #endif
104  }
105  };
106 
108  : QWidget(parent)
109  {
111  layout->setMargin(0);
112  QFrame *line = new QFrame(this);
115  layout->addWidget(line);
116  textEdit = new TextEdit();
117  textEdit->setFixedHeight(100);
119  textEdit->setReadOnly(true);
120  layout->addWidget(textEdit);
121  setLayout(layout);
122  }
123  void setText(const QString &text) { textEdit->setPlainText(text); }
124  QString text() const { return textEdit->toPlainText(); }
125 private:
127 };
128 #endif // QT_NO_TEXTEDIT
129 
130 class DetailButton : public QPushButton
131 {
132 public:
134  {
136  }
137 
139  { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); }
140 
142  { setText(label(lbl)); }
143 
144  QSize sizeHint() const
145  {
146  ensurePolished();
147  QStyleOptionButton opt;
148  initStyleOption(&opt);
149  const QFontMetrics fm = fontMetrics();
150  opt.text = label(ShowLabel);
151  QSize sz = fm.size(Qt::TextShowMnemonic, opt.text);
152  QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
153  expandedTo(QApplication::globalStrut());
154  opt.text = label(HideLabel);
155  sz = fm.size(Qt::TextShowMnemonic, opt.text);
156  ret = ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
157  expandedTo(QApplication::globalStrut()));
158  return ret;
159  }
160 };
161 
162 
164 {
166 
167 public:
168  QMessageBoxPrivate() : escapeButton(0), defaultButton(0), clickedButton(0), detailsButton(0),
169 #ifndef QT_NO_TEXTEDIT
170  detailsText(0),
171 #endif
172  compatMode(false), autoAddOkButton(true),
173  detectedEscapeButton(0), informativeLabel(0) { }
174 
175  void init(const QString &title = QString(), const QString &text = QString());
176  void _q_buttonClicked(QAbstractButton *);
177 
178  QAbstractButton *findButton(int button0, int button1, int button2, int flags);
179  void addOldButtons(int button0, int button1, int button2);
180 
181  QAbstractButton *abstractButtonForId(int id) const;
182  int execReturnCode(QAbstractButton *button);
183 
184  void detectEscapeButton();
185  void updateSize();
186  int layoutMinimumWidth();
187  void retranslateStrings();
188 
189 #ifdef Q_WS_WINCE
190  void hideSpecial();
191 #endif
192 
193  static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
194  const QString &title, const QString &text,
195  int button0, int button1, int button2);
196  static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
197  const QString &title, const QString &text,
198  const QString &button0Text,
199  const QString &button1Text,
200  const QString &button2Text,
201  int defaultButtonNumber,
202  int escapeButtonNumber);
203 
205  QMessageBox::Icon icon, const QString& title, const QString& text,
206  QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
207 
208  static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb);
209 
219 #ifndef QT_NO_TEXTEDIT
221 #endif
226 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
227  QTextBrowser *textBrowser;
228 #endif
232 };
233 
234 void QMessageBoxPrivate::init(const QString &title, const QString &text)
235 {
236  Q_Q(QMessageBox);
237 
238  label = new QLabel;
239  label->setObjectName(QLatin1String("qt_msgbox_label"));
240  label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
241  label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
242  label->setOpenExternalLinks(true);
243 #if defined(Q_WS_MAC)
244  label->setContentsMargins(16, 0, 0, 0);
245 #elif !defined(Q_WS_QWS)
246  label->setContentsMargins(2, 0, 0, 0);
247  label->setIndent(9);
248 #endif
249  icon = QMessageBox::NoIcon;
250  iconLabel = new QLabel;
251  iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label"));
252  iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
253 
254  buttonBox = new QDialogButtonBox;
255  buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox"));
256  buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q));
257  QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),
258  q, SLOT(_q_buttonClicked(QAbstractButton*)));
259 
260  QGridLayout *grid = new QGridLayout;
261 #ifndef Q_WS_MAC
262 #ifdef Q_WS_S60
263  const int preferredIconColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 1 : 0;
264  const int preferredTextColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 0 : 1;
265 #else
266  const int preferredIconColumn = 0;
267  const int preferredTextColumn = 1;
268 #endif
269  grid->addWidget(iconLabel, 0, preferredIconColumn, 2, 1, Qt::AlignTop);
270  grid->addWidget(label, 0, preferredTextColumn, 1, 1);
271  // -- leave space for information label --
272  grid->addWidget(buttonBox, 2, 0, 1, 2);
273 #else
274  grid->setMargin(0);
275  grid->setVerticalSpacing(8);
276  grid->setHorizontalSpacing(0);
277  q->setContentsMargins(24, 15, 24, 20);
278  grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignLeft);
279  grid->addWidget(label, 0, 1, 1, 1);
280  // -- leave space for information label --
281  grid->setRowStretch(1, 100);
282  grid->setRowMinimumHeight(2, 6);
283  grid->addWidget(buttonBox, 3, 1, 1, 1);
284 #endif
285 
287  q->setLayout(grid);
288 
289  if (!title.isEmpty() || !text.isEmpty()) {
290  q->setWindowTitle(title);
291  q->setText(text);
292  }
293  q->setModal(true);
294 
295 #ifdef Q_WS_MAC
296  QFont f = q->font();
297  f.setBold(true);
298  label->setFont(f);
299 #endif
300  retranslateStrings();
301 }
302 
304 {
305  layout->activate();
306  return layout->totalMinimumSize().width();
307 }
308 
310 {
311  Q_Q(QMessageBox);
312 
313  if (!q->isVisible())
314  return;
315 
317 #if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
318  // the width of the screen, less the window border.
319  int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
320 #else
321  int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
322  // on small screens allows the messagebox be the same size as the screen
323  if (screenSize.width() <= 1024)
324  hardLimit = screenSize.width();
325 #endif
326 #ifdef Q_WS_MAC
327  int softLimit = qMin(screenSize.width()/2, 420);
328 #elif defined(Q_WS_QWS)
329  int softLimit = qMin(hardLimit, 500);
330 #else
331  // note: ideally on windows, hard and soft limits but it breaks compat
332 #ifndef Q_WS_WINCE
333  int softLimit = qMin(screenSize.width()/2, 500);
334 #else
335  int softLimit = qMin(screenSize.width() * 3 / 4, 500);
336 #endif //Q_WS_WINCE
337 #endif
338 
339  if (informativeLabel)
340  informativeLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
341 
342  label->setWordWrap(false); // makes the label return min size
343  int width = layoutMinimumWidth();
344 
345  if (width > softLimit) {
346  label->setWordWrap(true);
347  width = qMax(softLimit, layoutMinimumWidth());
348 
349  if (width > hardLimit) {
350  label->d_func()->ensureTextControl();
351  if (QTextControl *control = label->d_func()->control) {
352  QTextOption opt = control->document()->defaultTextOption();
354  control->document()->setDefaultTextOption(opt);
355  }
356  width = hardLimit;
357  }
358  }
359 #ifdef Q_WS_S60
360  // in S60 portait messageBoxes should always occupy maximum width
362  width = hardLimit;
363  } else {
364  // in landscape the messageBoxes should be of same width as in portrait
365  width = qMin(QApplication::desktop()->size().height(), hardLimit);
366  }
367 #endif
368 
369  if (informativeLabel) {
370  label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
372  policy.setHeightForWidth(true);
373  informativeLabel->setSizePolicy(policy);
374  width = qMax(width, layoutMinimumWidth());
375  if (width > hardLimit) { // longest word is really big, so wrap anywhere
376  informativeLabel->d_func()->ensureTextControl();
377  if (QTextControl *control = informativeLabel->d_func()->control) {
378  QTextOption opt = control->document()->defaultTextOption();
380  control->document()->setDefaultTextOption(opt);
381  }
382  width = hardLimit;
383  }
384  policy.setHeightForWidth(label->wordWrap());
385  label->setSizePolicy(policy);
386  }
387 
388  QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
389  int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
390  if (windowTitleWidth > width)
391  width = windowTitleWidth;
392 
393  layout->activate();
394  int height = (layout->hasHeightForWidth())
395  ? layout->totalHeightForWidth(width)
397 
398 #ifndef QT_NO_STYLE_S60
399  QS60Style *s60Style = 0;
400  s60Style = qobject_cast<QS60Style *>(QApplication::style());
401 
402  //use custom pixel metric to deduce the minimum height of the messagebox
403  if (s60Style)
404  height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight));
405 #endif
406 
407  q->setFixedSize(width, height);
409 }
410 
411 
412 #ifdef Q_WS_WINCE
413 
423 {
424  Q_Q(QMessageBox);
425  QList<QPushButton*> list = q->findChildren<QPushButton*>();
426  for (int i=0; i<list.size(); ++i) {
427  QPushButton *pb = list.at(i);
428  QString text = pb->text();
429  text.remove(QChar::fromLatin1('&'));
430  if (text == QApplication::translate("QMessageBox", "OK" ))
431  pb->setFixedSize(0,0);
432  }
433 }
434 #endif
435 
436 static int oldButton(int button)
437 {
438  switch (button & QMessageBox::ButtonMask) {
439  case QMessageBox::Ok:
440  return Old_Ok;
441  case QMessageBox::Cancel:
442  return Old_Cancel;
443  case QMessageBox::Yes:
444  return Old_Yes;
445  case QMessageBox::No:
446  return Old_No;
447  case QMessageBox::Abort:
448  return Old_Abort;
449  case QMessageBox::Retry:
450  return Old_Retry;
451  case QMessageBox::Ignore:
452  return Old_Ignore;
454  return Old_YesAll;
456  return Old_NoAll;
457  default:
458  return 0;
459  }
460 }
461 
463 {
464  int ret = buttonBox->standardButton(button);
465  if (ret == QMessageBox::NoButton) {
466  ret = customButtonList.indexOf(button); // if button == 0, correctly sets ret = -1
467  } else if (compatMode) {
468  ret = oldButton(ret);
469  }
470  return ret;
471 }
472 
474 {
475  Q_Q(QMessageBox);
476 #ifndef QT_NO_TEXTEDIT
477  if (detailsButton && detailsText && button == detailsButton) {
478  detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
479  detailsText->setHidden(!detailsText->isHidden());
480  updateSize();
481  } else
482 #endif
483  {
484  clickedButton = button;
485  q->done(execReturnCode(button)); // does not trigger closeEvent
486  emit q->buttonClicked(button);
487 
488  if (receiverToDisconnectOnClose) {
489  QObject::disconnect(q, signalToDisconnectOnClose, receiverToDisconnectOnClose,
490  memberToDisconnectOnClose);
491  receiverToDisconnectOnClose = 0;
492  }
493  signalToDisconnectOnClose.clear();
494  memberToDisconnectOnClose.clear();
495  }
496 }
497 
778 {
779  Q_D(QMessageBox);
780  d->init();
781 }
782 
800  StandardButtons buttons, QWidget *parent,
801  Qt::WindowFlags f)
803 {
804  Q_D(QMessageBox);
805  d->init(title, text);
806  setIcon(icon);
807  if (buttons != NoButton)
808  setStandardButtons(buttons);
809 }
810 
815 {
816 }
817 
830 {
831  Q_D(QMessageBox);
832  if (!button)
833  return;
834  removeButton(button);
835  d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
836  d->customButtonList.append(button);
837  d->autoAddOkButton = false;
838 }
839 
851 {
852  Q_D(QMessageBox);
853  QPushButton *pushButton = new QPushButton(text);
854  addButton(pushButton, role);
855  d->updateSize();
856  return pushButton;
857 }
858 
872 {
873  Q_D(QMessageBox);
874  QPushButton *pushButton = d->buttonBox->addButton((QDialogButtonBox::StandardButton)button);
875  if (pushButton)
876  d->autoAddOkButton = false;
877  return pushButton;
878 }
879 
891 {
892  Q_D(QMessageBox);
893  d->customButtonList.removeAll(button);
894  if (d->escapeButton == button)
895  d->escapeButton = 0;
896  if (d->defaultButton == button)
897  d->defaultButton = 0;
898  d->buttonBox->removeButton(button);
899  d->updateSize();
900 }
901 
917 {
918  Q_D(QMessageBox);
919  d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));
920 
921  QList<QAbstractButton *> buttonList = d->buttonBox->buttons();
922  if (!buttonList.contains(d->escapeButton))
923  d->escapeButton = 0;
924  if (!buttonList.contains(d->defaultButton))
925  d->defaultButton = 0;
926  d->autoAddOkButton = false;
927  d->updateSize();
928 }
929 
930 QMessageBox::StandardButtons QMessageBox::standardButtons() const
931 {
932  Q_D(const QMessageBox);
933  return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
934 }
935 
948 {
949  Q_D(const QMessageBox);
950  return (QMessageBox::StandardButton)d->buttonBox->standardButton(button);
951 }
952 
965 {
966  Q_D(const QMessageBox);
967  return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
968 }
969 
994 {
995  Q_D(const QMessageBox);
996  return d->escapeButton;
997 }
998 
1011 {
1012  Q_D(QMessageBox);
1013  if (d->buttonBox->buttons().contains(button))
1014  d->escapeButton = button;
1015 }
1016 
1029 {
1030  Q_D(QMessageBox);
1031  setEscapeButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
1032 }
1033 
1035 {
1036  if (escapeButton) { // escape button explicitly set
1037  detectedEscapeButton = escapeButton;
1038  return;
1039  }
1040 
1041  // Cancel button automatically becomes escape button
1042  detectedEscapeButton = buttonBox->button(QDialogButtonBox::Cancel);
1043  if (detectedEscapeButton)
1044  return;
1045 
1046  // If there is only one button, make it the escape button
1047  const QList<QAbstractButton *> buttons = buttonBox->buttons();
1048  if (buttons.count() == 1) {
1049  detectedEscapeButton = buttons.first();
1050  return;
1051  }
1052 
1053  // if the message box has one RejectRole button, make it the escape button
1054  for (int i = 0; i < buttons.count(); i++) {
1055  if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::RejectRole) {
1056  if (detectedEscapeButton) { // already detected!
1057  detectedEscapeButton = 0;
1058  break;
1059  }
1060  detectedEscapeButton = buttons.at(i);
1061  }
1062  }
1063  if (detectedEscapeButton)
1064  return;
1065 
1066  // if the message box has one NoRole button, make it the escape button
1067  for (int i = 0; i < buttons.count(); i++) {
1068  if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::NoRole) {
1069  if (detectedEscapeButton) { // already detected!
1070  detectedEscapeButton = 0;
1071  break;
1072  }
1073  detectedEscapeButton = buttons.at(i);
1074  }
1075  }
1076 }
1077 
1097 {
1098  Q_D(const QMessageBox);
1099  return d->clickedButton;
1100 }
1101 
1115 {
1116  Q_D(const QMessageBox);
1117  return d->defaultButton;
1118 }
1119 
1132 {
1133  Q_D(QMessageBox);
1134  if (!d->buttonBox->buttons().contains(button))
1135  return;
1136  d->defaultButton = button;
1137  button->setDefault(true);
1138  button->setFocus();
1139 }
1140 
1153 {
1154  Q_D(QMessageBox);
1155  setDefaultButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
1156 }
1157 
1174 QString QMessageBox::text() const
1175 {
1176  Q_D(const QMessageBox);
1177  return d->label->text();
1178 }
1179 
1181 {
1182  Q_D(QMessageBox);
1183  d->label->setText(text);
1184  d->label->setWordWrap(d->label->textFormat() == Qt::RichText
1185  || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text)));
1186  d->updateSize();
1187 }
1188 
1240 {
1241  Q_D(const QMessageBox);
1242  return d->icon;
1243 }
1244 
1246 {
1247  Q_D(QMessageBox);
1249  this));
1250  d->icon = icon;
1251 }
1252 
1269 {
1270  Q_D(const QMessageBox);
1271  if (d->iconLabel && d->iconLabel->pixmap())
1272  return *d->iconLabel->pixmap();
1273  return QPixmap();
1274 }
1275 
1277 {
1278  Q_D(QMessageBox);
1279  d->iconLabel->setPixmap(pixmap);
1280  d->updateSize();
1281  d->icon = NoIcon;
1282 }
1283 
1298 {
1299  Q_D(const QMessageBox);
1300  return d->label->textFormat();
1301 }
1302 
1304 {
1305  Q_D(QMessageBox);
1306  d->label->setTextFormat(format);
1307  d->label->setWordWrap(format == Qt::RichText
1308  || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text())));
1309  d->updateSize();
1310 }
1311 
1316 {
1317  bool result =QDialog::event(e);
1318  switch (e->type()) {
1319  case QEvent::LayoutRequest:
1320  d_func()->updateSize();
1321  break;
1323  d_func()->retranslateStrings();
1324  break;
1325 #ifdef Q_WS_WINCE
1326  case QEvent::OkRequest:
1327  case QEvent::HelpRequest: {
1328  QString bName =
1329  (e->type() == QEvent::OkRequest)
1330  ? QApplication::translate("QMessageBox", "OK")
1331  : QApplication::translate("QMessageBox", "Help");
1332  QList<QPushButton*> list = findChildren<QPushButton*>();
1333  for (int i=0; i<list.size(); ++i) {
1334  QPushButton *pb = list.at(i);
1335  if (pb->text() == bName) {
1336  if (pb->isEnabled())
1337  pb->click();
1338  return pb->isEnabled();
1339  }
1340  }
1341  }
1342 #endif
1343  default:
1344  break;
1345  }
1346  return result;
1347 }
1348 
1353 {
1354  QDialog::resizeEvent(event);
1355 }
1356 
1361 {
1362  Q_D(QMessageBox);
1363  if (!d->detectedEscapeButton) {
1364  e->ignore();
1365  return;
1366  }
1368  d->clickedButton = d->detectedEscapeButton;
1369  setResult(d->execReturnCode(d->detectedEscapeButton));
1370 }
1371 
1376 {
1377  Q_D(QMessageBox);
1378  switch (ev->type()) {
1379  case QEvent::StyleChange:
1380  {
1381  if (d->icon != NoIcon)
1382  setIcon(d->icon);
1383  Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this));
1384  d->label->setTextInteractionFlags(flags);
1385  d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this));
1386  if (d->informativeLabel)
1387  d->informativeLabel->setTextInteractionFlags(flags);
1388  // intentional fall through
1389  }
1390  case QEvent::FontChange:
1392 #ifdef Q_WS_MAC
1393  {
1394  QFont f = font();
1395  f.setBold(true);
1396  d->label->setFont(f);
1397  }
1398 #endif
1399  default:
1400  break;
1401  }
1403 }
1404 
1409 {
1410  Q_D(QMessageBox);
1411  if (e->key() == Qt::Key_Escape
1412 #ifdef Q_WS_MAC
1413  || (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period)
1414 #endif
1415  ) {
1416  if (d->detectedEscapeButton) {
1417 #ifdef Q_WS_MAC
1418  d->detectedEscapeButton->animateClick();
1419 #else
1420  d->detectedEscapeButton->click();
1421 #endif
1422  }
1423  return;
1424  }
1425 
1426 #if defined (Q_OS_WIN) && !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
1427  if (e == QKeySequence::Copy) {
1428  QString separator = QString::fromLatin1("---------------------------\n");
1429  QString textToCopy = separator;
1430  separator.prepend(QLatin1Char('\n'));
1431  textToCopy += windowTitle() + separator; // title
1432  textToCopy += d->label->text() + separator; // text
1433 
1434  if (d->informativeLabel)
1435  textToCopy += d->informativeLabel->text() + separator;
1436 
1437  QString buttonTexts;
1438  QList<QAbstractButton *> buttons = d->buttonBox->buttons();
1439  for (int i = 0; i < buttons.count(); i++) {
1440  buttonTexts += buttons[i]->text() + QLatin1String(" ");
1441  }
1442  textToCopy += buttonTexts + separator;
1443 
1444  QApplication::clipboard()->setText(textToCopy);
1445  return;
1446  }
1447 #endif //QT_NO_SHORTCUT QT_NO_CLIPBOARD Q_OS_WIN
1448 
1449 #ifndef QT_NO_SHORTCUT
1450  if (!(e->modifiers() & Qt::AltModifier)) {
1451  int key = e->key() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL);
1452  if (key) {
1453  const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
1454  for (int i = 0; i < buttons.count(); ++i) {
1455  QAbstractButton *pb = buttons.at(i);
1456  int acc = pb->shortcut() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL);
1457  if (acc == key) {
1458  pb->animateClick();
1459  return;
1460  }
1461  }
1462  }
1463  }
1464 #endif
1466 }
1467 
1468 #ifdef Q_WS_WINCE
1469 
1473 {
1474  Q_D(QMessageBox);
1475  if (visible)
1476  d->hideSpecial();
1477  QDialog::setVisible(visible);
1478 }
1479 #endif
1480 
1481 
1495 void QMessageBox::open(QObject *receiver, const char *member)
1496 {
1497  Q_D(QMessageBox);
1498  const char *signal = member && strchr(member, '*') ? SIGNAL(buttonClicked(QAbstractButton*))
1499  : SIGNAL(finished(int));
1500  connect(this, signal, receiver, member);
1501  d->signalToDisconnectOnClose = signal;
1502  d->receiverToDisconnectOnClose = receiver;
1503  d->memberToDisconnectOnClose = member;
1504  QDialog::open();
1505 }
1506 
1518 {
1519  Q_D(const QMessageBox);
1520  return d->buttonBox->buttons();
1521 }
1522 
1535 {
1536  Q_D(const QMessageBox);
1537  return QMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
1538 }
1539 
1544 {
1545  Q_D(QMessageBox);
1546  if (d->autoAddOkButton) {
1547  addButton(Ok);
1548 #if defined(Q_WS_WINCE)
1549  d->hideSpecial();
1550 #endif
1551  }
1552  if (d->detailsButton)
1553  addButton(d->detailsButton, QMessageBox::ActionRole);
1554  d->detectEscapeButton();
1555  d->updateSize();
1556 
1557 #ifndef QT_NO_ACCESSIBILITY
1559 #endif
1560 #ifdef Q_WS_WIN
1561  HMENU systemMenu = GetSystemMenu((HWND)winId(), FALSE);
1562  if (!d->detectedEscapeButton) {
1563  EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
1564  }
1565  else {
1566  EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
1567  }
1568 #endif
1569  QDialog::showEvent(e);
1570 }
1571 
1572 
1575  const QString& title, const QString& text,
1576  QMessageBox::StandardButtons buttons,
1578 {
1579  // necessary for source compatibility with Qt 4.0 and 4.1
1580  // handles (Yes, No) and (Yes|Default, No)
1581  if (defaultButton && !(buttons & defaultButton))
1583  QMessageBoxPrivate::showOldMessageBox(parent, icon, title,
1584  text, int(buttons),
1585  int(defaultButton), 0);
1586 
1587  QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
1588  QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
1589  Q_ASSERT(buttonBox != 0);
1590 
1592  while (mask <= QMessageBox::LastButton) {
1593  uint sb = buttons & mask;
1594  mask <<= 1;
1595  if (!sb)
1596  continue;
1598  // Choose the first accept role as the default
1599  if (msgBox.defaultButton())
1600  continue;
1601  if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
1602  || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
1603  msgBox.setDefaultButton(button);
1604  }
1605  if (msgBox.exec() == -1)
1606  return QMessageBox::Cancel;
1607  return msgBox.standardButton(msgBox.clickedButton());
1608 }
1609 
1639  const QString& text, StandardButtons buttons,
1641 {
1642  return showNewMessageBox(parent, Information, title, text, buttons,
1643  defaultButton);
1644 }
1645 
1646 
1676  const QString& text, StandardButtons buttons,
1678 {
1679  return showNewMessageBox(parent, Question, title, text, buttons, defaultButton);
1680 }
1681 
1711  const QString& text, StandardButtons buttons,
1713 {
1714  return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton);
1715 }
1716 
1746  const QString& text, StandardButtons buttons,
1748 {
1749  return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton);
1750 }
1751 
1773 void QMessageBox::about(QWidget *parent, const QString &title, const QString &text)
1774 {
1775 #ifdef Q_WS_MAC
1776  static QPointer<QMessageBox> oldMsgBox;
1777 
1778  if (oldMsgBox && oldMsgBox->text() == text) {
1779  oldMsgBox->show();
1780  oldMsgBox->raise();
1781  oldMsgBox->activateWindow();
1782  return;
1783  }
1784 #endif
1785 
1786  QMessageBox *msgBox = new QMessageBox(title, text, Information, 0, 0, 0, parent
1787 #ifdef Q_WS_MAC
1789 #endif
1790  );
1792  QIcon icon = msgBox->windowIcon();
1793  QSize size = icon.actualSize(QSize(64, 64));
1794  msgBox->setIconPixmap(icon.pixmap(size));
1795 
1796  // should perhaps be a style hint
1797 #ifdef Q_WS_MAC
1798  oldMsgBox = msgBox;
1799 #if 0
1800  // ### doesn't work until close button is enabled in title bar
1801  msgBox->d_func()->autoAddOkButton = false;
1802 #else
1803  msgBox->d_func()->buttonBox->setCenterButtons(true);
1804 #endif
1805  msgBox->show();
1806 #else
1807  msgBox->exec();
1808 #endif
1809 }
1810 
1827 {
1828 #ifdef Q_WS_MAC
1829  static QPointer<QMessageBox> oldMsgBox;
1830 
1831  if (oldMsgBox) {
1832  oldMsgBox->show();
1833  oldMsgBox->raise();
1834  oldMsgBox->activateWindow();
1835  return;
1836  }
1837 #endif
1838 
1839  QString translatedTextAboutQtCaption;
1840  translatedTextAboutQtCaption = QMessageBox::tr(
1841  "<h3>About Qt</h3>"
1842  "<p>This program uses Qt version %1.</p>"
1844  QString translatedTextAboutQtText;
1845  translatedTextAboutQtText = QMessageBox::tr(
1846  "<p>Qt is a C++ toolkit for cross-platform application "
1847  "development.</p>"
1848  "<p>Qt provides single-source portability across MS&nbsp;Windows, "
1849  "Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. "
1850  "Qt is also available for embedded devices as Qt for Embedded Linux "
1851  "and Qt for Windows CE.</p>"
1852  "<p>Qt is available under three different licensing options designed "
1853  "to accommodate the needs of our various users.</p>"
1854  "<p>Qt licensed under our commercial license agreement is appropriate "
1855  "for development of proprietary/commercial software where you do not "
1856  "want to share any source code with third parties or otherwise cannot "
1857  "comply with the terms of the GNU LGPL version 2.1 or GNU GPL version "
1858  "3.0.</p>"
1859  "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "
1860  "development of Qt applications (proprietary or open source) provided "
1861  "you can comply with the terms and conditions of the GNU LGPL version "
1862  "2.1.</p>"
1863  "<p>Qt licensed under the GNU General Public License version 3.0 is "
1864  "appropriate for the development of Qt applications where you wish to "
1865  "use such applications in combination with software subject to the "
1866  "terms of the GNU GPL version 3.0 or where you are otherwise willing "
1867  "to comply with the terms of the GNU GPL version 3.0.</p>"
1868  "<p>Please see <a href=\"http://qt.digia.com/product/licensing\">qt.digia.com/product/licensing</a> "
1869  "for an overview of Qt licensing.</p>"
1870  "<p>Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).</p>"
1871  "<p>Qt is a Digia product. See <a href=\"http://qt.digia.com/\">qt.digia.com</a> "
1872  "for more information.</p>"
1873  );
1874  QMessageBox *msgBox = new QMessageBox(parent);
1876  msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
1877  msgBox->setText(translatedTextAboutQtCaption);
1878  msgBox->setInformativeText(translatedTextAboutQtText);
1879 
1880  QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
1881  if (!pm.isNull())
1882  msgBox->setIconPixmap(pm);
1883 #if defined(Q_WS_WINCE)
1884  msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));
1885 #endif
1886 
1887  // should perhaps be a style hint
1888 #ifdef Q_WS_MAC
1889  oldMsgBox = msgBox;
1890 #if 0
1891  // ### doesn't work until close button is enabled in title bar
1892  msgBox->d_func()->autoAddOkButton = false;
1893 #else
1894  msgBox->d_func()->buttonBox->setCenterButtons(true);
1895 #endif
1896  msgBox->show();
1897 #else
1898  msgBox->exec();
1899 #endif
1900 }
1901 
1906 {
1907  // ### Qt 5: remove
1908  return QDialog::sizeHint();
1909 }
1910 
1912 // Source and binary compatibility routines for 4.0 and 4.1
1913 
1915 {
1916  // this is needed for source compatibility with Qt 4.0 and 4.1
1917  if (button == QMessageBox::NoButton || (button & NewButtonMask))
1919 
1920 #if QT_VERSION < 0x050000
1921  // this is needed for binary compatibility with Qt 4.0 and 4.1
1922  switch (button & Old_ButtonMask) {
1923  case Old_Ok:
1924  return QMessageBox::Ok;
1925  case Old_Cancel:
1926  return QMessageBox::Cancel;
1927  case Old_Yes:
1928  return QMessageBox::Yes;
1929  case Old_No:
1930  return QMessageBox::No;
1931  case Old_Abort:
1932  return QMessageBox::Abort;
1933  case Old_Retry:
1934  return QMessageBox::Retry;
1935  case Old_Ignore:
1936  return QMessageBox::Ignore;
1937  case Old_YesAll:
1938  return QMessageBox::YesToAll;
1939  case Old_NoAll:
1940  return QMessageBox::NoToAll;
1941  default:
1942  return QMessageBox::NoButton;
1943  }
1944 #endif
1945 }
1946 
1947 static bool detectedCompat(int button0, int button1, int button2)
1948 {
1949  if (button0 != 0 && !(button0 & NewButtonMask))
1950  return true;
1951  if (button1 != 0 && !(button1 & NewButtonMask))
1952  return true;
1953  if (button2 != 0 && !(button2 & NewButtonMask))
1954  return true;
1955  return false;
1956 }
1957 
1958 QAbstractButton *QMessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)
1959 {
1960  Q_Q(QMessageBox);
1961  int button = 0;
1962 
1963  if (button0 & flags) {
1964  button = button0;
1965  } else if (button1 & flags) {
1966  button = button1;
1967  } else if (button2 & flags) {
1968  button = button2;
1969  }
1970  return q->button(newButton(button));
1971 }
1972 
1973 void QMessageBoxPrivate::addOldButtons(int button0, int button1, int button2)
1974 {
1975  Q_Q(QMessageBox);
1976  q->addButton(newButton(button0));
1977  q->addButton(newButton(button1));
1978  q->addButton(newButton(button2));
1979  q->setDefaultButton(
1980  static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));
1981  q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));
1982  compatMode = detectedCompat(button0, button1, button2);
1983 }
1984 
1986 {
1987  Q_Q(const QMessageBox);
1988  QAbstractButton *result = customButtonList.value(id);
1989  if (result)
1990  return result;
1991  if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
1992  return 0;
1993  return q->button(newButton(id));
1994 }
1995 
1997  const QString &title, const QString &text,
1998  int button0, int button1, int button2)
1999 {
2000  QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
2001  messageBox.d_func()->addOldButtons(button0, button1, button2);
2002  return messageBox.exec();
2003 }
2004 
2006  const QString &title, const QString &text,
2007  const QString &button0Text,
2008  const QString &button1Text,
2009  const QString &button2Text,
2010  int defaultButtonNumber,
2011  int escapeButtonNumber)
2012 {
2013  QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
2014  QString myButton0Text = button0Text;
2015  if (myButton0Text.isEmpty())
2016  myButton0Text = QDialogButtonBox::tr("OK");
2017  messageBox.addButton(myButton0Text, QMessageBox::ActionRole);
2018  if (!button1Text.isEmpty())
2019  messageBox.addButton(button1Text, QMessageBox::ActionRole);
2020  if (!button2Text.isEmpty())
2021  messageBox.addButton(button2Text, QMessageBox::ActionRole);
2022 
2023  const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;
2024  messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));
2025  messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));
2026 
2027  return messageBox.exec();
2028 }
2029 
2031 {
2032 #ifndef QT_NO_TEXTEDIT
2033  if (detailsButton)
2034  detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
2035 #endif
2036 }
2037 
2094  int button0, int button1, int button2, QWidget *parent,
2095  Qt::WindowFlags f)
2096  : QDialog(*new QMessageBoxPrivate, parent,
2097  f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
2098 {
2099  Q_D(QMessageBox);
2100  d->init(title, text);
2101  setIcon(icon);
2102  d->addOldButtons(button0, button1, button2);
2103 }
2104 
2148  int button0, int button1, int button2)
2149 {
2150  return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
2151  button0, button1, button2);
2152 }
2153 
2188  const QString& button0Text, const QString& button1Text,
2189  const QString& button2Text, int defaultButtonNumber,
2190  int escapeButtonNumber)
2191 {
2192  return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
2193  button0Text, button1Text, button2Text,
2194  defaultButtonNumber, escapeButtonNumber);
2195 }
2196 
2240  int button0, int button1, int button2)
2241 {
2242  return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
2243  button0, button1, button2);
2244 }
2245 
2279  const QString& button0Text, const QString& button1Text,
2280  const QString& button2Text, int defaultButtonNumber,
2281  int escapeButtonNumber)
2282 {
2283  return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
2284  button0Text, button1Text, button2Text,
2285  defaultButtonNumber, escapeButtonNumber);
2286 }
2287 
2288 
2332  int button0, int button1, int button2)
2333 {
2334  return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
2335  button0, button1, button2);
2336 }
2337 
2371  const QString& button0Text, const QString& button1Text,
2372  const QString& button2Text, int defaultButtonNumber,
2373  int escapeButtonNumber)
2374 {
2375  return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
2376  button0Text, button1Text, button2Text,
2377  defaultButtonNumber, escapeButtonNumber);
2378 }
2379 
2424  int button0, int button1, int button2)
2425 {
2426  return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
2427  button0, button1, button2);
2428 }
2429 
2463  const QString& button0Text, const QString& button1Text,
2464  const QString& button2Text, int defaultButtonNumber,
2465  int escapeButtonNumber)
2466 {
2467  return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
2468  button0Text, button1Text, button2Text,
2469  defaultButtonNumber, escapeButtonNumber);
2470 }
2471 
2472 
2485 {
2486  Q_D(const QMessageBox);
2487 
2488  if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
2489  return abstractButton->text();
2490  } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
2491  // for compatibility with Qt 4.0/4.1
2492  return QDialogButtonBox::tr("OK");
2493  }
2494  return QString();
2495 }
2496 
2510 {
2511  Q_D(QMessageBox);
2512  if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
2513  abstractButton->setText(text);
2514  } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
2515  // for compatibility with Qt 4.0/4.1
2516  addButton(QMessageBox::Ok)->setText(text);
2517  }
2518 }
2519 
2520 #ifndef QT_NO_TEXTEDIT
2521 
2536 {
2537  Q_D(const QMessageBox);
2538  return d->detailsText ? d->detailsText->text() : QString();
2539 }
2540 
2542 {
2543  Q_D(QMessageBox);
2544  if (text.isEmpty()) {
2545  delete d->detailsText;
2546  d->detailsText = 0;
2547  removeButton(d->detailsButton);
2548  delete d->detailsButton;
2549  d->detailsButton = 0;
2550  return;
2551  }
2552 
2553  if (!d->detailsText) {
2554  d->detailsText = new QMessageBoxDetailsText(this);
2556  if (grid)
2557  grid->addWidget(d->detailsText, grid->rowCount(), 0, 1, grid->columnCount());
2558  d->detailsText->hide();
2559  }
2560  if (!d->detailsButton)
2561  d->detailsButton = new DetailButton(this);
2562  d->detailsText->setText(text);
2563 }
2564 #endif // QT_NO_TEXTEDIT
2565 
2587 {
2588  Q_D(const QMessageBox);
2589  return d->informativeLabel ? d->informativeLabel->text() : QString();
2590 }
2591 
2593 {
2594  Q_D(QMessageBox);
2595  if (text.isEmpty()) {
2596  layout()->removeWidget(d->informativeLabel);
2597  delete d->informativeLabel;
2598  d->informativeLabel = 0;
2599 #ifndef Q_WS_MAC
2600  d->label->setContentsMargins(2, 0, 0, 0);
2601 #endif
2602  d->updateSize();
2603  return;
2604  }
2605 
2606  if (!d->informativeLabel) {
2607  QLabel *label = new QLabel(this);
2608  label->setObjectName(QLatin1String("qt_msgbox_informativelabel"));
2609  label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)));
2611  label->setOpenExternalLinks(true);
2612  label->setWordWrap(true);
2613 #ifndef Q_WS_MAC
2614  d->label->setContentsMargins(2, 0, 0, 0);
2615  label->setContentsMargins(2, 0, 0, 6);
2616  label->setIndent(9);
2617 #else
2618  label->setContentsMargins(16, 0, 0, 0);
2619  // apply a smaller font the information label on the mac
2620  label->setFont(qt_app_fonts_hash()->value("QTipLabel"));
2621 #endif
2622  label->setWordWrap(true);
2623  QGridLayout *grid = static_cast<QGridLayout *>(layout());
2624 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
2625  label->hide();
2626  QTextBrowser *textBrowser = new QTextBrowser(this);
2627  textBrowser->setOpenExternalLinks(true);
2628 #if defined(Q_OS_SYMBIAN)
2629  const int preferredTextColumn = (QApplication::layoutDirection() == Qt::LeftToRight) ? 0 : 1;
2630 #else
2631  const int preferredTextColumn = 1;
2632 #endif
2633  grid->addWidget(textBrowser, 1, preferredTextColumn, 1, 1);
2634  d->textBrowser = textBrowser;
2635 #else
2636  grid->addWidget(label, 1, 1, 1, 1);
2637 #endif
2638  d->informativeLabel = label;
2639  }
2640  d->informativeLabel->setText(text);
2641 
2642 #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
2643  //We need to put the informative label inside textBrowser to enable scrolling of long texts.
2644  d->textBrowser->setText(d->informativeLabel->text());
2645 #endif
2646 
2647  d->updateSize();
2648 }
2649 
2663 {
2664  // Message boxes on the mac do not have a title
2665 #ifndef Q_WS_MAC
2666  QDialog::setWindowTitle(title);
2667 #else
2668  Q_UNUSED(title);
2669 #endif
2670 }
2671 
2672 
2688 {
2689  QDialog::setWindowModality(windowModality);
2690 
2691  if (parentWidget() && windowModality == Qt::WindowModal)
2693  else
2695  setDefaultButton(d_func()->defaultButton);
2696 }
2697 
2698 #ifdef QT3_SUPPORT
2699 
2713 QMessageBox::QMessageBox(const QString& title,
2714  const QString &text, Icon icon,
2715  int button0, int button1, int button2,
2716  QWidget *parent, const char *name,
2717  bool modal, Qt::WindowFlags f)
2718  : QDialog(*new QMessageBoxPrivate, parent,
2719  f | Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WindowCloseButtonHint)
2720 {
2721  Q_D(QMessageBox);
2723  d->init(title, text);
2724  d->addOldButtons(button0, button1, button2);
2725  setModal(modal);
2726  setIcon(icon);
2727 }
2728 
2736 QMessageBox::QMessageBox(QWidget *parent, const char *name)
2737  : QDialog(*new QMessageBoxPrivate, parent,
2738  Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WindowCloseButtonHint)
2739 {
2740  Q_D(QMessageBox);
2742  d->init();
2743 }
2744 
2755 {
2756  Q_UNUSED(style);
2758 }
2759 
2801 #endif
2802 
2804 {
2805  QStyle *style = mb ? mb->style() : QApplication::style();
2806  int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb);
2807  QIcon tmpIcon;
2808  switch (icon) {
2810  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb);
2811  break;
2812  case QMessageBox::Warning:
2813  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb);
2814  break;
2815  case QMessageBox::Critical:
2816  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb);
2817  break;
2818  case QMessageBox::Question:
2819  tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb);
2820  default:
2821  break;
2822  }
2823  if (!tmpIcon.isNull())
2824  return tmpIcon.pixmap(iconSize, iconSize);
2825  return QPixmap();
2826 }
2827 
2845 {
2846  return QMessageBoxPrivate::standardIcon(icon, 0);
2847 }
2848 
2901 
2902 #include "moc_qmessagebox.cpp"
2903 
2904 #endif // QT_NO_MESSAGEBOX
void removeButton(QAbstractButton *button)
Removes button from the button box without deleting it.
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
static QMessageBox::StandardButton newButton(int button)
static void aboutQt(QWidget *parent, const QString &title=QString())
Displays a simple message box about Qt, with the given title and centered over parent (if parent is n...
void showEvent(QShowEvent *event)
Reimplemented Function
double d
Definition: qnumeric_p.h:62
static Qt::LayoutDirection layoutDirection()
Icon
This enum has the following values:
Definition: qmessagebox.h:76
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object&#39;s accessibility information.
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
void setFont(const QFont &)
Use the single-argument overload instead.
Definition: qwidget.cpp:4996
int width(const QString &, int len=-1) const
Returns the width in pixels of the first len characters of text.
int totalHeightForWidth(int w) const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:823
The QKeyEvent class describes a key event.
Definition: qevent.h:224
static QPixmap standardIcon(Icon icon)
Returns the pixmap used for a standard icon.
void setText(const QString &text)
void setTextFormat(Qt::TextFormat format)
void addOldButtons(int button0, int button1, int button2)
void keyPressEvent(QKeyEvent *)
Reimplemented Function
Definition: qdialog.cpp:695
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString text() const
QPointer< QObject > receiverToDisconnectOnClose
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Definition: qwidget.cpp:10479
void setWordWrap(bool on)
Definition: qlabel.cpp:579
DetailButton(QWidget *parent)
QSize size() const
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QString informativeText() const
QSize sizeHint() const
void ensurePolished() const
Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).
Definition: qwidget.cpp:10024
QAbstractButton * findButton(int button0, int button1, int button2, int flags)
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
QAbstractButton * clickedButton() const
Returns the button that was clicked by the user, or 0 if the user hit the Esc key and no escape butto...
void popup(const QPoint &pos, QAction *at=0)
Displays the menu so that the action atAction will be at the specified global position p...
Definition: qmenu.cpp:1847
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition: qevent.h:396
void setLayout(QLayout *)
Sets the layout manager for this widget to layout.
Definition: qwidget.cpp:10104
static QSize globalStrut()
DetailButtonLabel
Definition: qmessagebox.cpp:86
void setOpenExternalLinks(bool open)
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define QT_NO_TEXTEDIT
QString & prepend(QChar c)
Definition: qstring.h:261
#define SLOT(a)
Definition: qobjectdefs.h:226
QMessageBox(QWidget *parent=0)
Constructs a message box with no text and no buttons.
static Qt::MouseButtons buttons
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition: qmessagebox.h:59
PixelMetric
This enum describes the various available pixel metrics.
Definition: qstyle.h:474
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
void setDefault(bool)
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition: qsize.h:187
QString text() const
bool qt_wince_is_smartphone()
The QPushButton widget provides a command button.
Definition: qpushbutton.h:57
bool qt_wince_is_mobile()
bool activate()
Redoes the layout for parentWidget() if necessary.
Definition: qlayout.cpp:1249
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool event(QEvent *e)
Reimplemented Function
QMessageBoxDetailsText * detailsText
QList< QAbstractButton * > buttons() const
Returns a list of all the buttons that have been added to the message box.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QStyle * style()
Returns the application&#39;s style object.
void showEvent(QShowEvent *)
This event handler can be reimplemented in a subclass to receive widget show events which are passed ...
Definition: qdialog.cpp:838
DetailButton * detailsButton
QString text
the text of the button
Definition: qstyleoption.h:290
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
Definition: qlabel.cpp:820
QByteArray signalToDisconnectOnClose
The QString class provides a Unicode character string.
Definition: qstring.h:83
void closeEvent(QCloseEvent *event)
Reimplemented Function
T * qobject_cast(QObject *object)
Definition: qobject.h:375
virtual bool hasHeightForWidth() const
Returns true if this layout&#39;s preferred height depends on its width; otherwise returns false...
void setText(const QString &, Mode mode=Clipboard)
Copies text into the clipboard as plain text.
Definition: qclipboard.cpp:375
bool modal
whether show() should pop up the dialog as modal or modeless
Definition: qdialog.h:62
QPushButton * defaultButton
static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, int button0, int button1, int button2)
QAbstractButton * detectedEscapeButton
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
void setOpenExternalLinks(bool open)
Definition: qlabel.cpp:797
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QString label(DetailButtonLabel label) const
#define Q_D(Class)
Definition: qglobal.h:2482
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
int height() const
int rowCount() const
Returns the number of rows in this grid.
static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens a warning message box with the given title and text in front of the specified parent widget...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QString text
the message box text to be displayed.
Definition: qmessagebox.h:64
static QString translate(const char *context, const char *key, const char *disambiguation=0, Encoding encoding=CodecForTr)
QStyle * style() const
Definition: qwidget.cpp:2742
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define Q_Q(Class)
Definition: qglobal.h:2483
QFrame(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a frame widget with frame style NoFrame and a 1-pixel frame width.
Definition: qframe.cpp:219
static QFont font()
Returns the default application font.
void buttonClicked(QAbstractButton *button)
This signal is emitted whenever a button is clicked inside the QMessageBox.
QString toPlainText() const
Returns the text of the text edit as plain text.
Definition: qtextedit.h:189
void setHorizontalSpacing(int spacing)
void setHeightForWidth(bool b)
Definition: qsizepolicy.h:135
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void contextMenuEvent(QContextMenuEvent *e)
Shows the standard context menu created with createStandardContextMenu().
Definition: qmessagebox.cpp:95
QIcon windowIcon() const
void setWindowTitle(const QString &)
Definition: qwidget.cpp:6312
int columnCount() const
Returns the number of columns in this grid.
void setIconPixmap(const QPixmap &pixmap)
int width() const
Returns the width.
Definition: qsize.h:126
void addButton(QAbstractButton *button, ButtonRole role)
Adds the given button to the message box with the specified role.
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
Returns an icon for the given standardIcon.
Definition: qstyle.cpp:2327
void resizeEvent(QResizeEvent *)
Reimplemented Function
Definition: qdialog.cpp:1268
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setBold(bool)
If enable is true sets the font&#39;s weight to QFont::Bold ; otherwise sets the weight to QFont::Normal...
Definition: qfont.h:352
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QAbstractButton * button(StandardButton which) const
Returns a pointer corresponding to the standard button which, or 0 if the standard button doesn&#39;t exi...
bool visible
whether the widget is visible
Definition: qwidget.h:191
Qt::WindowModality windowModality() const
void init(const QString &title=QString(), const QString &text=QString())
friend class QPixmap
Definition: qwidget.h:748
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=0) const
Returns the size in pixels of text.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
int execReturnCode(QAbstractButton *button)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void raise()
Raises this widget to the top of the parent widget&#39;s stack.
Definition: qwidget.cpp:11901
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
void closeEvent(QCloseEvent *)
Reimplemented Function
Definition: qdialog.cpp:733
static bool init
int width() const
void setContentsMargins(int left, int top, int right, int bottom)
Sets the margins around the contents of the widget to have the sizes left, top, right, and bottom.
Definition: qwidget.cpp:7449
const char * name
QSize size() const
Returns the size of the rectangle.
Definition: qrect.h:309
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
#define emit
Definition: qobjectdefs.h:76
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition: qwidget.cpp:9170
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition: qicon.cpp:769
void setVisible(bool visible)
Reimplemented Function
QSize sizeHint() const
Reimplemented Function
Definition: qdialog.cpp:1160
QFontMetrics fontMetrics() const
Returns the font metrics for the widget&#39;s current font.
Definition: qwidget.h:984
The QResizeEvent class contains event parameters for resize events.
Definition: qevent.h:349
const char * styleHint(const QFontDef &request)
void setRowMinimumHeight(int row, int minSize)
Sets the minimum height of row row to minSize pixels.
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens a critical message box with the given title and text in front of the specified parent widget...
void setText(const QString &text)
unsigned int uint
Definition: qglobal.h:996
#define QT_VERSION_STR
This macro expands to a string that specifies Qt&#39;s version number (for example, "4.
Definition: qglobal.h:47
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158
ButtonRole buttonRole(QAbstractButton *button) const
Returns the button role for the specified button.
static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
FontHash * qt_app_fonts_hash()
#define FALSE
Synonym for false.
Definition: qglobal.h:1019
QMessageBoxDetailsText(QWidget *parent=0)
QAbstractButton * abstractButtonForId(int id) const
QString windowTitle() const
static QChar fromLatin1(char c)
Converts the Latin-1 character c to its equivalent QChar.
Definition: qchar.h:378
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
void setVerticalSpacing(int spacing)
void setWindowModality(Qt::WindowModality windowModality)
Definition: qwidget.cpp:2991
void setFrameShape(Shape)
Definition: qframe.cpp:284
void show()
Shows the widget and its child widgets.
The QShowEvent class provides an event that is sent when a widget is shown.
Definition: qevent.h:380
void _q_buttonClicked(QAbstractButton *)
void setInformativeText(const QString &text)
void setDetailedText(const QString &text)
ButtonRole buttonRole(QAbstractButton *button) const
Returns the button role for the specified button.
void setLabel(DetailButtonLabel lbl)
QPixmap iconPixmap() const
QRegion mask() const
Returns the mask currently set on a widget.
Definition: qwidget.cpp:10058
static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb)
bool isEnabled() const
Definition: qwidget.h:948
void hide()
Hides the widget.
Definition: qwidget.h:501
static void about(QWidget *parent, const QString &title, const QString &text)
Displays a simple about box with title title and text text.
QString detailedText() const
void setWindowModality(Qt::WindowModality windowModality)
This function shadows QWidget::setWindowModality().
QDialog(QWidget *parent=0, Qt::WindowFlags f=0)
Constructs a dialog with parent parent.
Definition: qdialog.cpp:268
TextFormat
Definition: qnamespace.h:1310
void setButtonText(int button, const QString &text)
Sets the text of the message box button button to text.
void setFrameShadow(Shadow)
Definition: qframe.cpp:306
static QDesktopWidget * desktop()
Returns the desktop widget (also called the root window).
QString text() const
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=0) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
void setResult(int r)
Sets the modal dialog&#39;s result code to i.
Definition: qdialog.cpp:475
T & first()
Returns a reference to the first item in the list.
Definition: qlist.h:282
QLabel * informativeLabel
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Definition: qobject.cpp:2895
void setFocus()
Gives the keyboard input focus to this widget (or its focus proxy) if this widget or one of its paren...
Definition: qwidget.h:432
void setPlainText(const QString &text)
Changes the text of the text edit to the string text.
Definition: qtextedit.cpp:1156
static bool detectedCompat(int button0, int button1, int button2)
void hideSpecial()
Hides special buttons which are rather shown in the title bar on WinCE, to conserve screen space...
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
bool qt_wince_is_pocket_pc()
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus...
Definition: qmenu.h:72
QPushButton * defaultButton() const
Returns the button that should be the message box&#39;s default button.
ButtonRole
Combinations of these roles are as flags used to describe different aspects of their behavior...
Definition: qmessagebox.h:84
QKeySequence shortcut
the mnemonic associated with the button
void setFixedSize(const QSize &)
Sets both the minimum and maximum sizes of the widget to s, thereby preventing it from ever growing o...
Definition: qwidget.cpp:4284
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
QAbstractButton * escapeButton() const
Returns the button that is activated when escape is pressed.
QMenu * createStandardContextMenu()
This function creates the standard context menu which is shown when the user clicks on the text edit ...
Definition: qtextedit.cpp:1834
friend class QPushButton
Definition: qdialog.h:59
void resizeEvent(QResizeEvent *event)
Reimplemented Function
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
StandardButton
These enums describe flags for standard buttons.
QSize actualSize(const QSize &size, Mode mode=Normal, State state=Off) const
Returns the actual size of the icon for the requested size, mode, and state.
Definition: qicon.cpp:730
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
int key
int result() const
In general returns the modal dialog&#39;s result code, Accepted or Rejected.
Definition: qdialog.cpp:458
The QGridLayout class lays out widgets in a grid.
Definition: qgridlayout.h:60
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens a question message box with the given title and text in front of the specified parent widget...
The QTextBrowser class provides a rich text browser with hypertext navigation.
Definition: qtextbrowser.h:58
int exec()
Shows the message box as a modal dialog, blocking until the user closes it.
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
void setStandardButtons(StandardButtons buttons)
QMessageBox::Icon icon
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
Definition: qstyle.h:68
Qt::TextFormat textFormat() const
bool event(QEvent *e)
Reimplemented Function
Definition: qdialog.cpp:426
void setDefaultButton(QPushButton *button)
Sets the message box&#39;s default button to button.
int height() const
Returns the height.
Definition: qsize.h:129
if(void) toggleToolbarShown
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
Opens an information message box with the given title and text in front of the specified parent widge...
Definition: qnamespace.h:54
StandardButton standardButton(QAbstractButton *button) const
Returns the standard button enum value corresponding to the given button, or NoButton if the given bu...
The QLabel widget provides a text or image display.
Definition: qlabel.h:55
The QTextOption class provides a description of general rich text properties.
Definition: qtextoption.h:59
static int oldButton(int button)
void activateWindow()
Sets the top-level widget containing this widget to be the active window.
QSize sizeHint() const
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
Definition: qwidget.cpp:11087
ButtonRole
This enum describes the roles that can be used to describe buttons in the button box.
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QSize totalMinimumSize() const
Also takes contentsMargins and menu bar into account.
Definition: qlayout.cpp:848
StandardButton
These enums describe flags for standard buttons.
Definition: qmessagebox.h:100
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition: qicon.cpp:693
void setIcon(Icon)
void setWindowTitle(const QString &title)
This function shadows QWidget::setWindowTitle().
void setWrapMode(WrapMode wrap)
Sets the option&#39;s text wrap mode to the given mode.
Definition: qtextoption.h:109
QLayout * layout() const
Returns the layout manager that is installed on this widget, or 0 if no layout manager is installed...
Definition: qwidget.cpp:10073
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
const QFont & font() const
Icon icon() const
void setSizeConstraint(SizeConstraint)
Definition: qlayout.cpp:1435
void open()
Shows the dialog as a window modal dialog, returning immediately.
Definition: qdialog.cpp:492
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
void setRowStretch(int row, int stretch)
Sets the stretch factor of row row to stretch.
void keyPressEvent(QKeyEvent *event)
Reimplemented Function
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
StandardButtons standardButtons() const
void click()
Performs a click.
void setEscapeButton(QAbstractButton *button)
Sets the button that gets activated when the Escape key is pressed to button.
removePostedEvents
Removes all events of the given eventType that were posted using postEvent() for receiver.
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition: qevent.h:413
const QRect availableGeometry(int screen=-1) const
The QVBoxLayout class lines up widgets vertically.
Definition: qboxlayout.h:149
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qgridlayout.h:116
QString buttonText(int button) const
Returns the text of the message box button button, or an empty string if the message box does not con...
void changeEvent(QEvent *event)
Reimplemented Function
void setModal(bool modal)
Definition: qdialog.cpp:1218
QString & remove(int i, int len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition: qstring.cpp:1867
QByteArray memberToDisconnectOnClose
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition: qpixmap.cpp:615
QList< QAbstractButton * > customButtonList
void setSizePolicy(QSizePolicy)
Definition: qwidget.cpp:10198
QAbstractButton * clickedButton
void setMargin(int)
Definition: qlayout.cpp:464
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
void finished(int result)
This signal is emitted when the dialog&#39;s result code has been set, either by the user or by calling d...
The QFrame class is the base class of widgets that can have a frame.
Definition: qframe.h:55
void setVisible(bool visible)
Reimplemented Function
Definition: qdialog.cpp:756
The QStyleOptionButton class is used to describe the parameters for drawing buttons.
Definition: qstyleoption.h:279
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void setReadOnly(bool ro)
Definition: qtextedit.cpp:2133
void setAlignment(Qt::Alignment)
Without this function, a call to e.
Definition: qlabel.cpp:532
void setText(const QString &text)
Sets the text edit&#39;s text.
Definition: qtextedit.cpp:2591
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
WindowModality
Definition: qnamespace.h:1683
QDialogButtonBox * buttonBox
The QCloseEvent class contains parameters that describe a close event.
Definition: qevent.h:364
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
Definition: qtextedit.h:70
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition: qlayout.cpp:1516
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310
void setFocusPolicy(Qt::FocusPolicy policy)
Definition: qwidget.cpp:7631
~QMessageBox()
Destroys the message box.
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
void setIndent(int)
Definition: qlabel.cpp:620
void animateClick(int msec=100)
Performs an animated click: the button is pressed immediately, and released msec milliseconds later (...
Button
Definition: qmessagebox.cpp:82
QAbstractButton * escapeButton
void setFixedHeight(int h)
Sets both the minimum and maximum heights of the widget to h without changing the widths...
Definition: qwidget.cpp:4388
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60