Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qmessagebox.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtWidgets/qmessagebox.h>
5
6#include <QtWidgets/qdialogbuttonbox.h>
7#include "private/qlabel_p.h"
8#include "private/qapplication_p.h"
9#include <QtCore/qlist.h>
10#include <QtCore/qdebug.h>
11#include <QtWidgets/qstyle.h>
12#include <QtWidgets/qstyleoption.h>
13#include <QtWidgets/qgridlayout.h>
14#include <QtWidgets/qpushbutton.h>
15#include <QtWidgets/qcheckbox.h>
16#include <QtGui/qaccessible.h>
17#include <QtGui/qicon.h>
18#include <QtGui/qtextdocument.h>
19#include <QtWidgets/qapplication.h>
20#if QT_CONFIG(textedit)
21#include <QtWidgets/qtextedit.h>
22#endif
23#if QT_CONFIG(menu)
24#include <QtWidgets/qmenu.h>
25#endif
26#include "qdialog_p.h"
27#include <QtGui/qfont.h>
28#include <QtGui/qfontmetrics.h>
29#include <QtGui/qclipboard.h>
30#include "private/qabstractbutton_p.h"
31#include <QtGui/qpa/qplatformtheme.h>
32
33#include <QtCore/qanystringview.h>
34#include <QtCore/qdebug.h>
35#include <QtCore/qpointer.h>
36#include <QtCore/qversionnumber.h>
37
38#ifdef Q_OS_WIN
39# include <QtCore/qt_windows.h>
40#include <qpa/qplatformnativeinterface.h>
41#endif
42
43#include <optional>
44
46
47using namespace Qt::StringLiterals;
48
49#if defined(Q_OS_WIN)
50HMENU qt_getWindowsSystemMenu(const QWidget *w)
51{
53 if (void *handle = QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", window))
54 return GetSystemMenu(reinterpret_cast<HWND>(handle), false);
55 return 0;
56}
57#endif
58
61 "QMessageBox::ButtonRole and QDialogButtonBox::ButtonRole out of sync!");
62
63static_assert(std::is_same_v<std::underlying_type_t<QMessageBox::ButtonRole>,
64 std::underlying_type_t<QDialogButtonBox::ButtonRole>>);
65
66// StandardButton enums have different underlying types
67// => qToUnderlying and std::is_same_v won't work
68// ### Qt 7: make them have the same underlying type
69static_assert(static_cast<int>(QMessageBox::StandardButton::LastButton) ==
71 "QMessageBox::StandardButton and QDialogButtonBox::StandardButton out of sync!");
72
73enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
75 NewButtonMask = 0xFFFFFC00 };
76
78#if QT_CONFIG(textedit)
79class QMessageBoxDetailsText : public QWidget
80{
82public:
83 class TextEdit : public QTextEdit
84 {
85 public:
86 TextEdit(QWidget *parent=nullptr) : QTextEdit(parent) { }
87#ifndef QT_NO_CONTEXTMENU
88 void contextMenuEvent(QContextMenuEvent * e) override
89 {
90 if (QMenu *menu = createStandardContextMenu()) {
92 menu->popup(e->globalPos());
93 }
94 }
95#endif // QT_NO_CONTEXTMENU
96 };
97
98 QMessageBoxDetailsText(QWidget *parent=nullptr)
99 : QWidget(parent)
100 , copyAvailable(false)
101 {
104 QFrame *line = new QFrame(this);
105 line->setFrameShape(QFrame::HLine);
106 line->setFrameShadow(QFrame::Sunken);
108 textEdit = new TextEdit();
109 textEdit->setFixedHeight(100);
111 textEdit->setReadOnly(true);
114
116 this, &QMessageBoxDetailsText::textCopyAvailable);
117 }
118 void setText(const QString &text) { textEdit->setPlainText(text); }
119 QString text() const { return textEdit->toPlainText(); }
120
121 bool copy()
122 {
123#ifdef QT_NO_CLIPBOARD
124 return false;
125#else
126 if (!copyAvailable)
127 return false;
128 textEdit->copy();
129 return true;
130#endif
131 }
132
133 void selectAll()
134 {
135 textEdit->selectAll();
136 }
137
138private slots:
139 void textCopyAvailable(bool available)
140 {
141 copyAvailable = available;
142 }
143
144private:
145 bool copyAvailable;
147};
148#endif // QT_CONFIG(textedit)
149
151{
152public:
157
159 { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); }
160
162 { setText(label(lbl)); }
163
164 QSize sizeHint() const override
165 {
169 const QFontMetrics fm = fontMetrics();
171 QSize sz = fm.size(Qt::TextShowMnemonic, opt.text);
174 sz = fm.size(Qt::TextShowMnemonic, opt.text);
175 ret = ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this));
176 return ret;
177 }
178};
179
181{
182 Q_DECLARE_PUBLIC(QMessageBox)
183
184public:
192
193 void init(const QString &title = QString(), const QString &text = QString());
194 void setupLayout();
198
199 QAbstractButton *findButton(int button0, int button1, int button2, int flags);
200 void addOldButtons(int button0, int button1, int button2);
201
204
205 void detectEscapeButton();
206 void updateSize();
207 int layoutMinimumWidth();
208 void retranslateStrings();
209
210 void setVisible(bool visible) override;
211 bool canBeNativeDialog() const override;
212
214 const QString &title, const QString &text,
215 int button0, int button1, int button2);
217 const QString &title, const QString &text,
218 const QString &button0Text,
219 const QString &button1Text,
220 const QString &button2Text,
221 int defaultButtonNumber,
222 int escapeButtonNumber);
223
226 QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
227
230
235 QList<QAbstractButton *> customButtonList;
241#if QT_CONFIG(textedit)
242 QMessageBoxDetailsText *detailsText;
243#endif
251 QSharedPointer<QMessageDialogOptions> options;
252private:
253 void initHelper(QPlatformDialogHelper *) override;
255 int dialogCode() const override;
256};
257
259{
260 Q_Q(QMessageBox);
261
262 label = new QLabel;
263 label->setObjectName("qt_msgbox_label"_L1);
264 label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, q)));
265 label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
266 label->setOpenExternalLinks(true);
267 iconLabel = new QLabel(q);
268 iconLabel->setObjectName("qt_msgboxex_icon_label"_L1);
270
272 buttonBox->setObjectName("qt_msgbox_buttonbox"_L1);
273 buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q));
276 setupLayout();
277 if (!title.isEmpty() || !text.isEmpty()) {
278 q->setWindowTitle(title);
279 q->setText(text);
280 }
281 q->setModal(true);
282#ifdef Q_OS_MAC
283 QFont f = q->font();
284 f.setBold(true);
285 label->setFont(f);
286#endif
288}
289
291{
292 Q_Q(QMessageBox);
293 delete q->layout();
294 QGridLayout *grid = new QGridLayout;
295 const bool hasIcon = !iconLabel->pixmap().isNull();
296
297 if (hasIcon)
298 grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
299 iconLabel->setVisible(hasIcon);
300#ifdef Q_OS_MAC
302#else
303 QSpacerItem *indentSpacer = new QSpacerItem(hasIcon ? 7 : 15, 1, QSizePolicy::Fixed, QSizePolicy::Fixed);
304#endif
305 grid->addItem(indentSpacer, 0, hasIcon ? 1 : 0, 2, 1);
306 grid->addWidget(label, 0, hasIcon ? 2 : 1, 1, 1);
307 if (informativeLabel) {
308#ifndef Q_OS_MAC
310#endif
311 grid->addWidget(informativeLabel, 1, hasIcon ? 2 : 1, 1, 1);
312 }
313 if (checkbox) {
314 grid->addWidget(checkbox, informativeLabel ? 2 : 1, hasIcon ? 2 : 1, 1, 1, Qt::AlignLeft);
315#ifdef Q_OS_MAC
316 grid->addItem(new QSpacerItem(1, 15, QSizePolicy::Fixed, QSizePolicy::Fixed), grid->rowCount(), 0);
317#else
319#endif
320 }
321#ifdef Q_OS_MAC
322 grid->addWidget(buttonBox, grid->rowCount(), hasIcon ? 2 : 1, 1, 1);
323 grid->setContentsMargins(0, 0, 0, 0);
324 grid->setVerticalSpacing(8);
325 grid->setHorizontalSpacing(0);
326 q->setContentsMargins(24, 15, 24, 20);
327 grid->setRowStretch(1, 100);
328 grid->setRowMinimumHeight(2, 6);
329#else
330 grid->addWidget(buttonBox, grid->rowCount(), 0, 1, grid->columnCount());
331#endif
332#if QT_CONFIG(textedit)
333 if (detailsText)
334 grid->addWidget(detailsText, grid->rowCount(), 0, 1, grid->columnCount());
335#endif
337 q->setLayout(grid);
338
340 updateSize();
341}
342
348
350{
351 Q_Q(QMessageBox);
352
353 if (!q->isVisible())
354 return;
355
356 const QSize screenSize = q->screen()->availableGeometry().size();
357 int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
358 // on small screens allows the messagebox be the same size as the screen
359 if (screenSize.width() <= 1024)
360 hardLimit = screenSize.width();
361#ifdef Q_OS_MAC
362 int softLimit = qMin(screenSize.width()/2, 420);
363#else
364 // note: ideally on windows, hard and soft limits but it breaks compat
365 int softLimit = qMin(screenSize.width()/2, 500);
366#endif
367
370
371 label->setWordWrap(false); // makes the label return min size
373
374 if (width > softLimit) {
375 label->setWordWrap(true);
376 width = qMax(softLimit, layoutMinimumWidth());
377
378 if (width > hardLimit) {
379 label->d_func()->ensureTextControl();
380 if (QWidgetTextControl *control = label->d_func()->control) {
381 QTextOption opt = control->document()->defaultTextOption();
382 opt.setWrapMode(QTextOption::WrapAnywhere);
383 control->document()->setDefaultTextOption(opt);
384 }
385 width = hardLimit;
386 }
387 }
388
389 if (informativeLabel) {
395 if (width > hardLimit) { // longest word is really big, so wrap anywhere
396 informativeLabel->d_func()->ensureTextControl();
397 if (QWidgetTextControl *control = informativeLabel->d_func()->control) {
398 QTextOption opt = control->document()->defaultTextOption();
399 opt.setWrapMode(QTextOption::WrapAnywhere);
400 control->document()->setDefaultTextOption(opt);
401 }
402 width = hardLimit;
403 }
404 policy.setHeightForWidth(label->wordWrap());
405 label->setSizePolicy(policy);
406 }
407
408 QFontMetrics fm(QApplication::font("QMdiSubWindowTitleBar"));
409 int windowTitleWidth = qMin(fm.horizontalAdvance(q->windowTitle()) + 50, hardLimit);
410 if (windowTitleWidth > width)
411 width = windowTitleWidth;
412
413 layout->activate();
417
418 q->setFixedSize(width, height);
420}
421
422static int oldButton(int button)
423{
425 case QMessageBox::Ok:
426 return Old_Ok;
428 return Old_Cancel;
429 case QMessageBox::Yes:
430 return Old_Yes;
431 case QMessageBox::No:
432 return Old_No;
434 return Old_Abort;
436 return Old_Retry;
438 return Old_Ignore;
440 return Old_YesAll;
442 return Old_NoAll;
443 default:
444 return 0;
445 }
446}
447
449{
450 if (int standardButton = buttonBox->standardButton(button)) {
451 // When using a QMessageBox with standard buttons, the return
452 // code is a StandardButton value indicating the standard button
453 // that was clicked.
454 if (compatMode)
455 return oldButton(standardButton);
456 else
457 return standardButton;
458 } else {
459 // When using QMessageBox with custom buttons, the return code
460 // is an opaque value, and the user is expected to use clickedButton()
461 // to determine which button was clicked. We make sure to keep the opaque
462 // value out of the QDialog::DialogCode range, so we can distinguish them.
463 auto customButtonIndex = customButtonList.indexOf(button);
464 if (customButtonIndex >= 0)
465 return QDialog::DialogCode::Accepted + customButtonIndex + 1;
466 else
467 return customButtonIndex; // Not found, return -1
468 }
469}
470
472{
473 Q_Q(const QMessageBox);
474
475 if (rescode <= QDialog::Accepted) {
476 return rescode;
477 } else if (clickedButton) {
478 switch (q->buttonRole(clickedButton)) {
481 return QDialog::Accepted;
484 return QDialog::Rejected;
485 default:
486 ;
487 }
488 }
489
491}
492
494{
495 Q_Q(QMessageBox);
496#if QT_CONFIG(textedit)
497 if (detailsButton && detailsText && button == detailsButton) {
498 detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
499 detailsText->setHidden(!detailsText->isHidden());
500 updateSize();
501 } else
502#endif
503 {
505
510 }
513 }
514}
515
517{
518 Q_Q(QMessageBox);
519
521 emit q->buttonClicked(clickedButton);
522
523 auto resultCode = execReturnCode(button);
524 q->done(resultCode);
525}
526
528{
529 Q_UNUSED(role);
530 Q_Q(QMessageBox);
531
532 // Map back to QAbstractButton, so that the message box behaves the same from
533 // the outside, regardless of whether it's backed by a native helper or not.
534 QAbstractButton *dialogButton = helperButton > QPlatformDialogHelper::LastButton ?
535 static_cast<QAbstractButton *>(options->customButton(helperButton)->button) :
536 q->button(QMessageBox::StandardButton(helperButton));
537
538 Q_ASSERT(dialogButton);
539
540 // Simulate click by explicitly clicking the button. This will ensure that
541 // any logic of the button that responds to the click is respected, including
542 // plumbing back to buttonClicked above based on the clicked() signal.
543 dialogButton->click();
544}
545
839 : QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
840{
841 Q_D(QMessageBox);
842 d->init();
843}
844
864 StandardButtons buttons, QWidget *parent,
865 Qt::WindowFlags f)
866: QDialog(*new QMessageBoxPrivate, parent, f | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
867{
868 Q_D(QMessageBox);
869 d->init(title, text);
870 setIcon(icon);
871 if (buttons != NoButton)
873}
874
881
891{
892 Q_D(QMessageBox);
893 if (!button)
894 return;
896
897 if (button->text().isEmpty()) {
898 if (auto *platformTheme = QGuiApplicationPrivate::platformTheme()) {
900 button->setText(platformTheme->standardButtonText(standardButton));
901 }
902
903 if (button->text().isEmpty()) {
904 qWarning() << "Cannot add" << button << "without title";
905 return;
906 }
907 }
908
909 d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
910 d->customButtonList.append(button);
911 d->autoAddOkButton = false;
912}
913
928
937{
938 Q_D(QMessageBox);
940 addButton(pushButton, role);
941 d->updateSize();
942 return pushButton;
943}
944
955{
956 Q_D(QMessageBox);
958 if (pushButton)
959 d->autoAddOkButton = false;
960 return pushButton;
961}
962
971{
972 Q_D(QMessageBox);
973 d->customButtonList.removeAll(button);
974 if (d->escapeButton == button)
975 d->escapeButton = nullptr;
976 if (d->defaultButton == button)
977 d->defaultButton = nullptr;
978 d->buttonBox->removeButton(button);
979 d->updateSize();
980}
981
993void QMessageBox::setStandardButtons(StandardButtons buttons)
994{
995 Q_D(QMessageBox);
996 d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));
997
998 QList<QAbstractButton *> buttonList = d->buttonBox->buttons();
999 if (!buttonList.contains(d->escapeButton))
1000 d->escapeButton = nullptr;
1001 if (!buttonList.contains(d->defaultButton))
1002 d->defaultButton = nullptr;
1003 d->autoAddOkButton = false;
1004 d->updateSize();
1005}
1006
1007QMessageBox::StandardButtons QMessageBox::standardButtons() const
1008{
1009 Q_D(const QMessageBox);
1010 return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
1011}
1012
1022{
1023 Q_D(const QMessageBox);
1024 return (QMessageBox::StandardButton)d->buttonBox->standardButton(button);
1025}
1026
1042{
1043 Q_D(const QMessageBox);
1044 return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
1045}
1046
1068{
1069 Q_D(const QMessageBox);
1070 return d->escapeButton;
1071}
1072
1082{
1083 Q_D(QMessageBox);
1084 if (d->buttonBox->buttons().contains(button))
1085 d->escapeButton = button;
1086}
1087
1101
1103{
1104 if (escapeButton) { // escape button explicitly set
1106 return;
1107 }
1108
1109 // Cancel button automatically becomes escape button
1112 return;
1113
1114 // If there is only one button, make it the escape button
1115 const QList<QAbstractButton *> buttons = buttonBox->buttons();
1116 if (buttons.size() == 1) {
1117 detectedEscapeButton = buttons.first();
1118 return;
1119 }
1120
1121 // If there are two buttons and one of them is the "Show Details..."
1122 // button, then make the other one the escape button
1123 if (buttons.size() == 2 && detailsButton) {
1124 auto idx = buttons.indexOf(detailsButton);
1125 if (idx != -1) {
1126 detectedEscapeButton = buttons.at(1 - idx);
1127 return;
1128 }
1129 }
1130
1131 // if the message box has one RejectRole button, make it the escape button
1132 for (auto *button : buttons) {
1134 if (detectedEscapeButton) { // already detected!
1135 detectedEscapeButton = nullptr;
1136 break;
1137 }
1139 }
1140 }
1142 return;
1143
1144 // if the message box has one NoRole button, make it the escape button
1145 for (auto *button : buttons) {
1147 if (detectedEscapeButton) { // already detected!
1148 detectedEscapeButton = nullptr;
1149 break;
1150 }
1152 }
1153 }
1154}
1155
1172{
1173 Q_D(const QMessageBox);
1174 return d->clickedButton;
1175}
1176
1187{
1188 Q_D(const QMessageBox);
1189 return d->defaultButton;
1190}
1191
1201{
1202 Q_D(QMessageBox);
1203 if (!d->buttonBox->buttons().contains(button))
1204 return;
1205 d->defaultButton = button;
1206 button->setDefault(true);
1207 button->setFocus();
1208}
1209
1223
1233{
1234 Q_D(QMessageBox);
1235
1236 if (cb == d->checkbox)
1237 return;
1238
1239 if (d->checkbox) {
1240 d->checkbox->hide();
1241 layout()->removeWidget(d->checkbox);
1242 if (d->checkbox->parentWidget() == this) {
1243 d->checkbox->setParent(nullptr);
1244 d->checkbox->deleteLater();
1245 }
1246 }
1247 d->checkbox = cb;
1248 if (d->checkbox) {
1249 QSizePolicy sp = d->checkbox->sizePolicy();
1250 sp.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
1251 d->checkbox->setSizePolicy(sp);
1252 }
1253 d->setupLayout();
1254}
1255
1256
1264{
1265 Q_D(const QMessageBox);
1266 return d->checkbox;
1267}
1268
1286{
1287 const QMessageBox::Options previousOptions = options();
1288 if (!(previousOptions & option) != !on)
1289 setOptions(previousOptions ^ option);
1290}
1291
1301{
1302 Q_D(const QMessageBox);
1303 return d->options->testOption(static_cast<QMessageDialogOptions::Option>(option));
1304}
1305
1306void QMessageBox::setOptions(QMessageBox::Options options)
1307{
1308 Q_D(QMessageBox);
1309
1311 return;
1312
1313 d->options->setOptions(QMessageDialogOptions::Option(int(options)));
1314}
1315
1316QMessageBox::Options QMessageBox::options() const
1317{
1318 Q_D(const QMessageBox);
1319 return QMessageBox::Options(int(d->options->options()));
1320}
1321
1358{
1359 Q_D(const QMessageBox);
1360 return d->label->text();
1361}
1362
1364{
1365 Q_D(QMessageBox);
1366 d->label->setText(text);
1367 d->label->setWordWrap(d->label->textFormat() == Qt::RichText
1368 || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text)));
1369 d->updateSize();
1370}
1371
1418{
1419 Q_D(const QMessageBox);
1420 return d->icon;
1421}
1422
1430
1444{
1445 Q_D(const QMessageBox);
1446 return d->iconLabel->pixmap();
1447}
1448
1450{
1451 Q_D(QMessageBox);
1452 d->iconLabel->setPixmap(pixmap);
1453 d->icon = NoIcon;
1454 d->setupLayout();
1455}
1456
1469{
1470 Q_D(const QMessageBox);
1471 return d->label->textFormat();
1472}
1473
1475{
1476 Q_D(QMessageBox);
1477 d->label->setTextFormat(format);
1478 d->label->setWordWrap(format == Qt::RichText
1479 || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text())));
1480 if (d->informativeLabel)
1481 d->informativeLabel->setTextFormat(format);
1482 d->updateSize();
1483}
1484
1497Qt::TextInteractionFlags QMessageBox::textInteractionFlags() const
1498{
1499 Q_D(const QMessageBox);
1500 return d->label->textInteractionFlags();
1501}
1502
1503void QMessageBox::setTextInteractionFlags(Qt::TextInteractionFlags flags)
1504{
1505 Q_D(QMessageBox);
1506 d->label->setTextInteractionFlags(flags);
1507}
1508
1513{
1514 bool result =QDialog::event(e);
1515 switch (e->type()) {
1517 d_func()->updateSize();
1518 break;
1520 d_func()->retranslateStrings();
1521 break;
1522 default:
1523 break;
1524 }
1525 return result;
1526}
1527
1535
1540{
1541 Q_D(QMessageBox);
1542 if (!d->detectedEscapeButton) {
1543 e->ignore();
1544 return;
1545 }
1547 if (!d->clickedButton) {
1548 d->clickedButton = d->detectedEscapeButton;
1549 setResult(d->execReturnCode(d->detectedEscapeButton));
1550 }
1551}
1552
1557{
1558 Q_D(QMessageBox);
1559 switch (ev->type()) {
1561 {
1562 if (d->icon != NoIcon)
1563 setIcon(d->icon);
1564 Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this));
1565 d->label->setTextInteractionFlags(flags);
1566 d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, this));
1567 if (d->informativeLabel)
1568 d->informativeLabel->setTextInteractionFlags(flags);
1569 Q_FALLTHROUGH();
1570 }
1571 case QEvent::FontChange:
1573#ifdef Q_OS_MAC
1574 {
1575 QFont f = font();
1576 f.setBold(true);
1577 d->label->setFont(f);
1578 }
1579#endif
1580 Q_FALLTHROUGH();
1581 default:
1582 break;
1583 }
1585}
1586
1591{
1592#if QT_CONFIG(shortcut)
1593 Q_D(QMessageBox);
1594 if (e->matches(QKeySequence::Cancel)) {
1595 if (d->detectedEscapeButton) {
1596#ifdef Q_OS_MAC
1597 d->detectedEscapeButton->animateClick();
1598#else
1599 d->detectedEscapeButton->click();
1600#endif
1601 }
1602 return;
1603 }
1604#endif // QT_CONFIG(shortcut)
1605
1606#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
1607
1608#if QT_CONFIG(textedit)
1609 if (e == QKeySequence::Copy) {
1610 if (d->detailsText && d->detailsText->isVisible() && d->detailsText->copy()) {
1611 e->setAccepted(true);
1612 return;
1613 }
1614 } else if (e == QKeySequence::SelectAll && d->detailsText && d->detailsText->isVisible()) {
1615 d->detailsText->selectAll();
1616 e->setAccepted(true);
1617 return;
1618 }
1619#endif // QT_CONFIG(textedit)
1620
1621#if defined(Q_OS_WIN)
1622 if (e == QKeySequence::Copy) {
1623 const auto separator = "---------------------------\n"_L1;
1624 QString textToCopy;
1625 textToCopy += separator + windowTitle() + u'\n' + separator // title
1626 + d->label->text() + u'\n' + separator; // text
1627
1628 if (d->informativeLabel)
1629 textToCopy += d->informativeLabel->text() + u'\n' + separator;
1630
1631 const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
1632 for (const auto *button : buttons)
1633 textToCopy += button->text() + " "_L1;
1634 textToCopy += u'\n' + separator;
1635#if QT_CONFIG(textedit)
1636 if (d->detailsText)
1637 textToCopy += d->detailsText->text() + u'\n' + separator;
1638#endif
1639 QGuiApplication::clipboard()->setText(textToCopy);
1640 return;
1641 }
1642#endif // Q_OS_WIN
1643
1644#endif // !QT_NO_CLIPBOARD && !QT_NO_SHORTCUT
1645
1646#ifndef QT_NO_SHORTCUT
1648 int key = e->key() & ~Qt::MODIFIER_MASK;
1649 if (key) {
1650 const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
1651 for (auto *pb : buttons) {
1652 QKeySequence shortcut = pb->shortcut();
1653 if (!shortcut.isEmpty() && key == shortcut[0].key()) {
1654 pb->animateClick();
1655 return;
1656 }
1657 }
1658 }
1659 }
1660#endif
1662}
1663
1672void QMessageBox::open(QObject *receiver, const char *member)
1673{
1674 Q_D(QMessageBox);
1675 const char *signal = member && strchr(member, '*') ? SIGNAL(buttonClicked(QAbstractButton*))
1676 : SIGNAL(finished(int));
1677 connect(this, signal, receiver, member);
1678 d->signalToDisconnectOnClose = signal;
1679 d->receiverToDisconnectOnClose = receiver;
1680 d->memberToDisconnectOnClose = member;
1681 QDialog::open();
1682}
1683
1685{
1686 Q_Q(QMessageBox);
1687
1688 // Last minute setup
1689 if (autoAddOkButton)
1690 q->addButton(QMessageBox::Ok);
1692
1693 if (canBeNativeDialog())
1694 setNativeDialogVisible(visible);
1695
1696 // Update WA_DontShowOnScreen based on whether the native dialog was shown,
1697 // so that QDialog::setVisible(visible) below updates the QWidget state correctly,
1698 // but skips showing the non-native version.
1700
1702}
1703
1711QList<QAbstractButton *> QMessageBox::buttons() const
1712{
1713 Q_D(const QMessageBox);
1714 return d->buttonBox->buttons();
1715}
1716
1726{
1727 Q_D(const QMessageBox);
1728 return QMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
1729}
1730
1735{
1736 Q_D(QMessageBox);
1737 d->clickedButton = nullptr;
1738 d->updateSize();
1739
1740#if QT_CONFIG(accessibility)
1741 QAccessibleEvent event(this, QAccessible::Alert);
1742 QAccessible::updateAccessibility(&event);
1743#endif
1744#if defined(Q_OS_WIN)
1745 if (const HMENU systemMenu = qt_getWindowsSystemMenu(this)) {
1746 EnableMenuItem(systemMenu, SC_CLOSE, d->detectedEscapeButton ?
1747 MF_BYCOMMAND|MF_ENABLED : MF_BYCOMMAND|MF_GRAYED);
1748 }
1749#endif
1751}
1752
1753
1756 const QString& title, const QString& text,
1757 QMessageBox::StandardButtons buttons,
1758 QMessageBox::StandardButton defaultButton)
1759{
1760 // necessary for source compatibility with Qt 4.0 and 4.1
1761 // handles (Yes, No) and (Yes|Default, No)
1762 if (defaultButton && !(buttons & defaultButton)) {
1763 const int defaultButtons = defaultButton | QMessageBox::Default;
1764 const int otherButtons = buttons.toInt();
1766 text, otherButtons,
1767 defaultButtons, 0);
1768 return static_cast<QMessageBox::StandardButton>(ret);
1769 }
1770
1773 Q_ASSERT(buttonBox != nullptr);
1774
1776 while (mask <= QMessageBox::LastButton) {
1777 uint sb = buttons & mask;
1778 mask <<= 1;
1779 if (!sb)
1780 continue;
1782 // Choose the first accept role as the default
1783 if (msgBox.defaultButton())
1784 continue;
1785 if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
1786 || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
1788 }
1789 if (msgBox.exec() == -1)
1790 return QMessageBox::Cancel;
1792}
1793
1820 const QString& text, StandardButtons buttons,
1821 StandardButton defaultButton)
1822{
1825}
1826
1827
1854 const QString& text, StandardButtons buttons,
1855 StandardButton defaultButton)
1856{
1858}
1859
1886 const QString& text, StandardButtons buttons,
1887 StandardButton defaultButton)
1888{
1890}
1891
1918 const QString& text, StandardButtons buttons,
1919 StandardButton defaultButton)
1920{
1922}
1923
1946{
1947#ifdef Q_OS_MAC
1948 static QPointer<QMessageBox> oldMsgBox;
1949
1950 if (oldMsgBox && oldMsgBox->text() == text) {
1951 oldMsgBox->show();
1952 oldMsgBox->raise();
1953 oldMsgBox->activateWindow();
1954 return;
1955 }
1956#endif
1957
1959#ifdef Q_OS_MAC
1961#endif
1962 );
1965 QSize size = icon.actualSize(QSize(64, 64));
1966 msgBox->setIconPixmap(icon.pixmap(size));
1967
1968 // should perhaps be a style hint
1969#ifdef Q_OS_MAC
1970 oldMsgBox = msgBox;
1971 auto *d = msgBox->d_func();
1972 d->buttonBox->setCenterButtons(true);
1973#ifdef Q_OS_IOS
1974 msgBox->setModal(true);
1975#else
1976 msgBox->setModal(false);
1977#endif
1978 msgBox->show();
1979#else
1980 msgBox->exec();
1981#endif
1982}
1983
2000{
2001#ifdef Q_OS_MAC
2002 static QPointer<QMessageBox> oldMsgBox;
2003
2004 if (oldMsgBox) {
2005 oldMsgBox->show();
2006 oldMsgBox->raise();
2007 oldMsgBox->activateWindow();
2008 return;
2009 }
2010#endif
2011
2012 QString translatedTextAboutQtCaption;
2013 translatedTextAboutQtCaption = QMessageBox::tr(
2014 "<h3>About Qt</h3>"
2015 "<p>This program uses Qt version %1.</p>"
2016 ).arg(QT_VERSION_STR ""_L1);
2017 //: Leave this text untranslated or include a verbatim copy of it below
2018 //: and note that it is the authoritative version in case of doubt.
2019 const QString translatedTextAboutQtText = QMessageBox::tr(
2020 "<p>Qt is a C++ toolkit for cross-platform application "
2021 "development.</p>"
2022 "<p>Qt provides single-source portability across all major desktop "
2023 "operating systems. It is also available for embedded Linux and other "
2024 "embedded and mobile operating systems.</p>"
2025 "<p>Qt is available under multiple licensing options designed "
2026 "to accommodate the needs of our various users.</p>"
2027 "<p>Qt licensed under our commercial license agreement is appropriate "
2028 "for development of proprietary/commercial software where you do not "
2029 "want to share any source code with third parties or otherwise cannot "
2030 "comply with the terms of GNU (L)GPL.</p>"
2031 "<p>Qt licensed under GNU (L)GPL is appropriate for the "
2032 "development of Qt&nbsp;applications provided you can comply with the terms "
2033 "and conditions of the respective licenses.</p>"
2034 "<p>Please see <a href=\"https://%2/\">%2</a> "
2035 "for an overview of Qt licensing.</p>"
2036 "<p>Copyright (C) The Qt Company Ltd. and other "
2037 "contributors.</p>"
2038 "<p>Qt and the Qt logo are trademarks of The Qt Company Ltd.</p>"
2039 "<p>Qt is The Qt Company Ltd. product developed as an open source "
2040 "project. See <a href=\"https://%3/\">%3</a> for more information.</p>"
2041 ).arg(QStringLiteral("qt.io/licensing"),
2042 QStringLiteral("qt.io"));
2045 msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
2046 msgBox->setText(translatedTextAboutQtCaption);
2047 msgBox->setInformativeText(translatedTextAboutQtText);
2048
2049 QPixmap pm(":/qt-project.org/qmessagebox/images/qtlogo-64.png"_L1);
2050 if (!pm.isNull())
2051 msgBox->setIconPixmap(pm);
2052
2053 // should perhaps be a style hint
2054#ifdef Q_OS_MAC
2055 oldMsgBox = msgBox;
2056 auto *d = msgBox->d_func();
2057 d->buttonBox->setCenterButtons(true);
2058#ifdef Q_OS_IOS
2059 msgBox->setModal(true);
2060#else
2061 msgBox->setModal(false);
2062#endif
2063 msgBox->show();
2064#else
2065 msgBox->exec();
2066#endif
2067}
2068
2070// Source and binary compatibility routines for 4.0 and 4.1
2071
2073{
2074 // this is needed for source compatibility with Qt 4.0 and 4.1
2077
2078 return QMessageBox::NoButton;
2079}
2080
2081static bool detectedCompat(int button0, int button1, int button2)
2082{
2083 if (button0 != 0 && !(button0 & NewButtonMask))
2084 return true;
2085 if (button1 != 0 && !(button1 & NewButtonMask))
2086 return true;
2087 if (button2 != 0 && !(button2 & NewButtonMask))
2088 return true;
2089 return false;
2090}
2091
2092QAbstractButton *QMessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)
2093{
2094 Q_Q(QMessageBox);
2095 int button = 0;
2096
2097 if (button0 & flags) {
2098 button = button0;
2099 } else if (button1 & flags) {
2100 button = button1;
2101 } else if (button2 & flags) {
2102 button = button2;
2103 }
2104 return q->button(newButton(button));
2105}
2106
2107void QMessageBoxPrivate::addOldButtons(int button0, int button1, int button2)
2108{
2109 Q_Q(QMessageBox);
2110 q->addButton(newButton(button0));
2111 q->addButton(newButton(button1));
2112 q->addButton(newButton(button2));
2113 q->setDefaultButton(
2114 static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));
2115 q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));
2116 compatMode = detectedCompat(button0, button1, button2);
2117}
2118
2120{
2121 Q_Q(const QMessageBox);
2123 if (result)
2124 return result;
2125 if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
2126 return nullptr;
2127 return q->button(newButton(id));
2128}
2129
2131 const QString &title, const QString &text,
2132 int button0, int button1, int button2)
2133{
2135 messageBox.d_func()->addOldButtons(button0, button1, button2);
2136 return messageBox.exec();
2137}
2138
2140 const QString &title, const QString &text,
2141 const QString &button0Text,
2142 const QString &button1Text,
2143 const QString &button2Text,
2144 int defaultButtonNumber,
2145 int escapeButtonNumber)
2146{
2148 QString myButton0Text = button0Text;
2149 if (myButton0Text.isEmpty())
2150 myButton0Text = QDialogButtonBox::tr("OK");
2152 if (!button1Text.isEmpty())
2154 if (!button2Text.isEmpty())
2156
2157 const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;
2158 messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));
2159 messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));
2160
2161 return messageBox.exec();
2162}
2163
2165{
2166#if QT_CONFIG(textedit)
2167 if (detailsButton && detailsText)
2168 detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
2169#endif
2170}
2171
2172#if QT_DEPRECATED_SINCE(6,2)
2226 int button0, int button1, int button2, QWidget *parent,
2227 Qt::WindowFlags f)
2228 : QDialog(*new QMessageBoxPrivate, parent,
2229 f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
2230{
2231 Q_D(QMessageBox);
2232 d->init(title, text);
2233 setIcon(icon);
2234 d->addOldButtons(button0, button1, button2);
2235}
2236
2276int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,
2277 int button0, int button1, int button2)
2278{
2280 button0, button1, button2);
2281}
2282
2313int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,
2314 const QString& button0Text, const QString& button1Text,
2315 const QString& button2Text, int defaultButtonNumber,
2316 int escapeButtonNumber)
2317{
2319 button0Text, button1Text, button2Text,
2320 defaultButtonNumber, escapeButtonNumber);
2321}
2322
2363int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,
2364 int button0, int button1, int button2)
2365{
2367 button0, button1, button2);
2368}
2369
2399int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,
2400 const QString& button0Text, const QString& button1Text,
2401 const QString& button2Text, int defaultButtonNumber,
2402 int escapeButtonNumber)
2403{
2405 button0Text, button1Text, button2Text,
2406 defaultButtonNumber, escapeButtonNumber);
2407}
2408
2409
2449int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,
2450 int button0, int button1, int button2)
2451{
2453 button0, button1, button2);
2454}
2455
2485int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,
2486 const QString& button0Text, const QString& button1Text,
2487 const QString& button2Text, int defaultButtonNumber,
2488 int escapeButtonNumber)
2489{
2491 button0Text, button1Text, button2Text,
2492 defaultButtonNumber, escapeButtonNumber);
2493}
2494
2535int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,
2536 int button0, int button1, int button2)
2537{
2539 button0, button1, button2);
2540}
2541
2571int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,
2572 const QString& button0Text, const QString& button1Text,
2573 const QString& button2Text, int defaultButtonNumber,
2574 int escapeButtonNumber)
2575{
2577 button0Text, button1Text, button2Text,
2578 defaultButtonNumber, escapeButtonNumber);
2579}
2580
2581
2590QString QMessageBox::buttonText(int button) const
2591{
2592 Q_D(const QMessageBox);
2593
2594 if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
2595 return abstractButton->text();
2596 } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
2597 // for compatibility with Qt 4.0/4.1
2598 return QDialogButtonBox::tr("OK");
2599 }
2600 return QString();
2601}
2602
2612void QMessageBox::setButtonText(int button, const QString &text)
2613{
2614 Q_D(QMessageBox);
2615 if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
2616 abstractButton->setText(text);
2617 } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
2618 // for compatibility with Qt 4.0/4.1
2619 addButton(QMessageBox::Ok)->setText(text);
2620 }
2621}
2622#endif // QT_DEPRECATED_SINCE(6,2)
2623
2624
2625#if QT_CONFIG(textedit)
2637QString QMessageBox::detailedText() const
2638{
2639 Q_D(const QMessageBox);
2640 return d->detailsText ? d->detailsText->text() : QString();
2641}
2642
2643void QMessageBox::setDetailedText(const QString &text)
2644{
2645 Q_D(QMessageBox);
2646 if (text.isEmpty()) {
2647 if (d->detailsText) {
2648 d->detailsText->hide();
2649 d->detailsText->deleteLater();
2650 }
2651 d->detailsText = nullptr;
2652 removeButton(d->detailsButton);
2653 if (d->detailsButton) {
2654 d->detailsButton->hide();
2655 d->detailsButton->deleteLater();
2656 }
2657 d->detailsButton = nullptr;
2658 } else {
2659 if (!d->detailsText) {
2660 d->detailsText = new QMessageBoxDetailsText(this);
2661 d->detailsText->hide();
2662 }
2663 if (!d->detailsButton) {
2664 const bool autoAddOkButton = d->autoAddOkButton; // QTBUG-39334, addButton() clears the flag.
2665 d->detailsButton = new DetailButton(this);
2666 addButton(d->detailsButton, QMessageBox::ActionRole);
2667 d->autoAddOkButton = autoAddOkButton;
2668 }
2669 d->detailsText->setText(text);
2670 }
2671 d->setupLayout();
2672}
2673#endif // QT_CONFIG(textedit)
2674
2697{
2698 Q_D(const QMessageBox);
2699 return d->informativeLabel ? d->informativeLabel->text() : QString();
2700}
2701
2703{
2704 Q_D(QMessageBox);
2705 if (text.isEmpty()) {
2706 if (d->informativeLabel) {
2707 d->informativeLabel->hide();
2708 d->informativeLabel->deleteLater();
2709 }
2710 d->informativeLabel = nullptr;
2711 } else {
2712 if (!d->informativeLabel) {
2713 QLabel *label = new QLabel;
2714 label->setObjectName("qt_msgbox_informativelabel"_L1);
2715 label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this)));
2716 label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
2717 label->setOpenExternalLinks(true);
2718#ifdef Q_OS_MAC
2719 // apply a smaller font the information label on the mac
2720 label->setFont(qt_app_fonts_hash()->value("QTipLabel"));
2721#endif
2722 label->setWordWrap(true);
2723 label->setTextFormat(d->label->textFormat());
2724 d->informativeLabel = label;
2725 }
2726 d->informativeLabel->setText(text);
2727 }
2728 d->setupLayout();
2729}
2730
2741{
2742 // Message boxes on the mac do not have a title
2743#ifndef Q_OS_MAC
2745#else
2746 Q_UNUSED(title);
2747#endif
2748}
2749
2750
2772
2773
2775{
2776 QStyle *style = mb ? mb->style() : QApplication::style();
2777 int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, mb);
2778 QIcon tmpIcon;
2779 switch (icon) {
2781 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, mb);
2782 break;
2784 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, mb);
2785 break;
2787 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, mb);
2788 break;
2790 tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb);
2791 break;
2792 default:
2793 break;
2794 }
2795 if (!tmpIcon.isNull()) {
2796 qreal dpr = mb ? mb->devicePixelRatio() : qApp->devicePixelRatio();
2797 return tmpIcon.pixmap(QSize(iconSize, iconSize), dpr);
2798 }
2799 return QPixmap();
2800}
2801
2803{
2804 auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(h);
2807 // Forward state via lambda, so that we can handle addition and removal
2808 // of checkbox via setCheckBox() after initializing helper.
2810 q_ptr, [this](Qt::CheckState state) {
2811 if (checkbox)
2813 }
2814 );
2815 messageDialogHelper->setOptions(options);
2816}
2817
2834
2835static QPlatformDialogHelper::StandardButtons helperStandardButtons(QMessageBox * q)
2836{
2837 QPlatformDialogHelper::StandardButtons buttons(int(q->standardButtons()));
2838 return buttons;
2839}
2840
2842{
2843 // Don't use Q_Q here! This function is called from ~QDialog,
2844 // so Q_Q calling q_func() invokes undefined behavior (invalid cast in q_func()).
2845 const QDialog * const q = static_cast<const QMessageBox*>(q_ptr);
2847 return true;
2849 || q->testAttribute(Qt::WA_DontShowOnScreen)
2850 || q->testAttribute(Qt::WA_StyleSheet)
2852 return false;
2853 }
2854
2855 if (strcmp(QMessageBox::staticMetaObject.className(), q->metaObject()->className()) != 0)
2856 return false;
2857
2858#if QT_CONFIG(menu)
2859 for (auto *customButton : buttonBox->buttons()) {
2860 if (QPushButton *pushButton = qobject_cast<QPushButton *>(customButton)) {
2861 // We can't support buttons with menus in native dialogs (yet)
2862 if (pushButton->menu())
2863 return false;
2864 }
2865 }
2866#endif
2867
2869}
2870
2872{
2873 Q_Q(QMessageBox);
2874 options->setWindowTitle(q->windowTitle());
2875 options->setText(q->text());
2876 options->setInformativeText(q->informativeText());
2877#if QT_CONFIG(textedit)
2878 options->setDetailedText(q->detailedText());
2879#endif
2881 options->setIconPixmap(q->iconPixmap());
2882
2883 // Clear up front, since we might have prepared earlier
2885
2886 // Add standard buttons and resolve default/escape button
2887 auto standardButtons = helperStandardButtons(q);
2890 auto *standardButton = buttonBox->button(QDialogButtonBox::StandardButton(button));
2891 if (!standardButton)
2892 continue;
2893
2894 if (auto *platformTheme = QGuiApplicationPrivate::platformTheme()) {
2895 if (standardButton->text() != platformTheme->standardButtonText(button)) {
2896 // The standard button has been customized, so add it as
2897 // a custom button instead.
2898 const auto buttonRole = buttonBox->buttonRole(standardButton);
2899 options->addButton(standardButton->text(),
2900 static_cast<QPlatformDialogHelper::ButtonRole>(buttonRole),
2901 standardButton, button);
2902 standardButtons &= ~QPlatformDialogHelper::StandardButton(button);
2903 }
2904 }
2905
2906 if (standardButton == defaultButton)
2908 else if (standardButton == detectedEscapeButton)
2910 }
2911 options->setStandardButtons(standardButtons);
2912
2913 // Add custom buttons and resolve default/escape button
2914 for (auto *customButton : customButtonList) {
2915 // Unless it's the details button, since we don't do any
2916 // plumbing for the button's action in that case.
2917 if (customButton == detailsButton)
2918 continue;
2919
2920 const auto buttonRole = buttonBox->buttonRole(customButton);
2921 const int buttonId = options->addButton(customButton->text(),
2922 static_cast<QPlatformDialogHelper::ButtonRole>(buttonRole),
2923 customButton);
2924
2925 if (customButton == defaultButton)
2926 options->setDefaultButton(buttonId);
2927 else if (customButton == detectedEscapeButton)
2928 options->setEscapeButton(buttonId);
2929 }
2930
2931 if (checkbox)
2933}
2934
2935void qRequireVersion(int argc, char *argv[], QAnyStringView req)
2936{
2937 const auto required = QVersionNumber::fromString(req).normalized();
2938 const auto current = QVersionNumber::fromString(qVersion()).normalized();
2939 if (current >= required)
2940 return;
2941 std::optional<QApplication> application;
2942 if (!qApp)
2943 application.emplace(argc, argv);
2944 const QString message = QApplication::tr("Application \"%1\" requires Qt %2, found Qt %3.")
2945 .arg(qAppName(), required.toString(), current.toString());
2946 QMessageBox::critical(nullptr, QApplication::tr("Incompatible Qt Library Error"),
2949}
2950
2951#if QT_DEPRECATED_SINCE(6,2)
2965QPixmap QMessageBox::standardIcon(Icon icon)
2966{
2967 return QMessageBoxPrivate::standardIcon(icon, nullptr);
2968}
2969#endif
2970
3037
3038#include "moc_qmessagebox.cpp"
3039#include "qmessagebox.moc"
DetailButton(QWidget *parent)
QString label(DetailButtonLabel label) const
void setLabel(DetailButtonLabel lbl)
QSize sizeHint() const override
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
void setText(const QString &text)
QString text
the text shown on the button
\inmodule QtCore
static QWindow * windowForWidget(const QWidget *widget)
static QStyle * style()
Returns the application's style object.
static QFont font()
Returns the default application font.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
\inmodule QtCore
Definition qbytearray.h:57
void clear()
Clears the contents of the byte array and makes it null.
The QCheckBox widget provides a checkbox with a text label.
Definition qcheckbox.h:19
void setCheckState(Qt::CheckState state)
Sets the checkbox's check state to state.
Qt::CheckState checkState() const
Returns the checkbox's check state.
The QCloseEvent class contains parameters that describe a close event.
Definition qevent.h:562
The QContextMenuEvent class contains parameters that describe a context menu event.
Definition qevent.h:594
const QPoint & globalPos() const
Returns the global position of the mouse pointer at the time of the event.
Definition qevent.h:612
static void removePostedEvents(QObject *receiver, int eventType=0)
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void clicked(QAbstractButton *button)
This signal is emitted when a button inside the button box is clicked.
ButtonRole buttonRole(QAbstractButton *button) const
Returns the button role for the specified button.
StandardButton
These enums describe flags for standard buttons.
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or \nullptr if the standard butto...
StandardButton standardButton(QAbstractButton *button) const
Returns the standard button enum value corresponding to the given button, or NoButton if the given bu...
void setCenterButtons(bool center)
QList< QAbstractButton * > buttons() const
Returns a list of all buttons that have been added to the button box.
bool setNativeDialogVisible(bool visible)
Definition qdialog.cpp:162
virtual void setVisible(bool visible)
Definition qdialog.cpp:754
virtual bool canBeNativeDialog() const
Definition qdialog.cpp:99
bool nativeDialogInUse
Definition qdialog_p.h:86
virtual int dialogCode() const
Definition qdialog_p.h:93
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
void closeEvent(QCloseEvent *) override
\reimp
Definition qdialog.cpp:721
void finished(int result)
void setResult(int r)
Sets the modal dialog's result code to i.
Definition qdialog.cpp:489
void keyPressEvent(QKeyEvent *) override
\reimp
Definition qdialog.cpp:684
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:543
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
Definition qdialog.cpp:475
@ Accepted
Definition qdialog.h:30
@ Rejected
Definition qdialog.h:30
void setModal(bool modal)
Definition qdialog.cpp:1004
void resizeEvent(QResizeEvent *) override
\reimp
Definition qdialog.cpp:1054
void showEvent(QShowEvent *) override
\reimp
Definition qdialog.cpp:853
friend class QPushButton
[1]
Definition qdialog.h:21
virtual void open()
Definition qdialog.cpp:503
\inmodule QtCore
Definition qcoreevent.h:45
virtual void setAccepted(bool accepted)
Definition qcoreevent.h:307
@ StyleChange
Definition qcoreevent.h:136
@ LayoutRequest
Definition qcoreevent.h:112
@ FontChange
Definition qcoreevent.h:133
@ LanguageChange
Definition qcoreevent.h:123
@ ApplicationFontChange
Definition qcoreevent.h:91
Type type() const
Returns the event type.
Definition qcoreevent.h:304
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition qcoreevent.h:311
\reentrant \inmodule QtGui
\reentrant
Definition qfont.h:22
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
Definition qfont.h:373
The QFrame class is the base class of widgets that can have a frame.
Definition qframe.h:17
@ Sunken
Definition qframe.h:51
@ HLine
Definition qframe.h:43
void setFocusPolicy(Qt::FocusPolicy policy)
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:21
void setHorizontalSpacing(int spacing)
void addWidget(QWidget *w)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qgridlayout.h:64
void setRowMinimumHeight(int row, int minSize)
Sets the minimum height of row row to minSize pixels.
int rowCount() const
Returns the number of rows in this grid.
void addItem(QLayoutItem *item, int row, int column, int rowSpan=1, int columnSpan=1, Qt::Alignment=Qt::Alignment())
Adds item at position row, column, spanning rowSpan rows and columnSpan columns, and aligns it accord...
void setVerticalSpacing(int spacing)
void setRowStretch(int row, int stretch)
Sets the stretch factor of row row to stretch.
int columnCount() const
Returns the number of columns in this grid.
static QPlatformTheme * platformTheme()
static QPlatformNativeInterface * platformNativeInterface()
static QClipboard * clipboard()
Returns the object for interacting with the clipboard.
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
The QKeyEvent class describes a key event.
Definition qevent.h:424
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition qevent.cpp:1468
int key() const
Returns the code of the key that was pressed or released.
Definition qevent.h:434
The QKeySequence class encapsulates a key sequence as used by shortcuts.
The QLabel widget provides a text or image display.
Definition qlabel.h:20
QPixmap pixmap
the label's pixmap.
Definition qlabel.h:24
virtual bool hasHeightForWidth() const
Returns true if this layout's preferred height depends on its width; otherwise returns false.
int totalHeightForWidth(int w) const
Definition qlayout.cpp:599
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition qlayout.cpp:1323
void setSizeConstraint(SizeConstraint)
Definition qlayout.cpp:1241
bool activate()
Redoes the layout for parentWidget() if necessary.
Definition qlayout.cpp:995
QSize totalMinimumSize() const
Definition qlayout.cpp:621
@ SetNoConstraint
Definition qlayout.h:37
void setContentsMargins(int left, int top, int right, int bottom)
Definition qlayout.cpp:288
T value(qsizetype i) const
Definition qlist.h:664
\inmodule QtCore
Definition qmargins.h:24
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
void popup(const QPoint &pos, QAction *at=nullptr)
Displays the menu so that the action atAction will be at the specified global position p.
Definition qmenu.cpp:2310
QDialogButtonBox * buttonBox
QAbstractButton * abstractButtonForId(int id) const
QList< QAbstractButton * > customButtonList
void initHelper(QPlatformDialogHelper *) override
DetailButton * detailsButton
int execReturnCode(QAbstractButton *button)
QMessageBox::Icon icon
bool canBeNativeDialog() const override
void addOldButtons(int button0, int button1, int button2)
void buttonClicked(QAbstractButton *)
static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb)
void init(const QString &title=QString(), const QString &text=QString())
QAbstractButton * clickedButton
QPushButton * defaultButton
int dialogCode() const override
QSharedPointer< QMessageDialogOptions > options
void setVisible(bool visible) override
QAbstractButton * escapeButton
QPointer< QObject > receiverToDisconnectOnClose
static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, int button0, int button1, int button2)
QByteArray memberToDisconnectOnClose
void helperPrepareShow(QPlatformDialogHelper *) override
QAbstractButton * findButton(int button0, int button1, int button2, int flags)
void setClickedButton(QAbstractButton *button)
static QMessageBox::StandardButton standardButtonForRole(QMessageBox::ButtonRole role)
void helperClicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
QAbstractButton * detectedEscapeButton
QByteArray signalToDisconnectOnClose
The QMessageBox class provides a modal dialog for informing the user or for asking the user a questio...
Definition qmessagebox.h:22
QList< QAbstractButton * > buttons() const
void closeEvent(QCloseEvent *event) override
\reimp
void changeEvent(QEvent *event) override
\reimp
void setEscapeButton(QAbstractButton *button)
bool testOption(Option option) const
void setStandardButtons(StandardButtons buttons)
void setWindowTitle(const QString &title)
static StandardButton warning(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void buttonClicked(QAbstractButton *button)
This signal is emitted whenever a button is clicked inside the QMessageBox.
Qt::TextFormat textFormat
the format of the text displayed by the message box
Definition qmessagebox.h:27
void setIcon(Icon)
StandardButtons standardButtons
collection of standard buttons in the message box
Definition qmessagebox.h:28
void keyPressEvent(QKeyEvent *event) override
\reimp
QMessageBox(QWidget *parent=nullptr)
Constructs an \l{Qt::ApplicationModal} {application modal} message box with no text and no buttons.
~QMessageBox()
Destroys the message box.
void addButton(QAbstractButton *button, ButtonRole role)
bool event(QEvent *e) override
\reimp
void removeButton(QAbstractButton *button)
void setInformativeText(const QString &text)
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 resizeEvent(QResizeEvent *event) override
\reimp
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void setOptions(Options options)
void setTextFormat(Qt::TextFormat format)
static StandardButton critical(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
void showEvent(QShowEvent *event) override
\reimp
static void about(QWidget *parent, const QString &title, const QString &text)
Displays a simple about box with title title and text text.
QString text
the message box text to be displayed.
Definition qmessagebox.h:24
Icon icon
the message box's icon
Definition qmessagebox.h:25
QPushButton * defaultButton() const
Options options
Options that affect the look and feel of the dialog.
Definition qmessagebox.h:35
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
void setWindowModality(Qt::WindowModality windowModality)
QAbstractButton * clickedButton() const
static StandardButton question(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=StandardButtons(Yes|No), StandardButton defaultButton=NoButton)
Icon
This enum has the following values:
Definition qmessagebox.h:43
void setIconPixmap(const QPixmap &pixmap)
Qt::TextInteractionFlags textInteractionFlags
Definition qmessagebox.h:34
void setCheckBox(QCheckBox *cb)
StandardButton standardButton(QAbstractButton *button) const
void setOption(Option option, bool on=true)
QPixmap iconPixmap
the current icon
Definition qmessagebox.h:26
virtual void open()
Definition qdialog.cpp:503
QAbstractButton * escapeButton() const
ButtonRole buttonRole(QAbstractButton *button) const
void setText(const QString &text)
void setDefaultButton(QPushButton *button)
QString informativeText
the informative text that provides a fuller description for the message
Definition qmessagebox.h:32
QAbstractButton * button(StandardButton which) const
QCheckBox * checkBox() const
void setWindowTitle(const QString &)
void setInformativeText(const QString &text)
void setDetailedText(const QString &text)
void setText(const QString &text)
int addButton(const QString &label, QPlatformDialogHelper::ButtonRole role, void *buttonImpl=nullptr, int buttonId=0)
void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons)
const CustomButton * customButton(int id)
void setCheckBox(const QString &label, Qt::CheckState state)
void setStandardIcon(StandardIcon icon)
void setIconPixmap(const QPixmap &pixmap)
QObject * q_ptr
Definition qobject.h:72
QObject * parent
Definition qobject.h:73
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:299
\inmodule QtCore
Definition qobject.h:103
T findChild(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns the child of this object that can be cast into type T and that is called name,...
Definition qobject.h:155
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual bool event(QEvent *event)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition qobject.cpp:1389
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3236
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:127
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition qpixmap.cpp:456
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
The QPlatformMessageDialogHelper class allows for platform-specific customization of Message dialogs.
void checkBoxStateChanged(Qt::CheckState state)
void clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
void setDefault(bool)
virtual void initStyleOption(QStyleOptionButton *option) const
Initialize option with the values from this QPushButton.
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
The QShowEvent class provides an event that is sent when a widget is shown.
Definition qevent.h:578
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
Definition qsizepolicy.h:18
constexpr void setHeightForWidth(bool b) noexcept
Sets the flag determining whether the widget's preferred height depends on its width,...
Definition qsizepolicy.h:80
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
constexpr QSize expandedTo(const QSize &) const noexcept
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition qsize.h:192
The QSpacerItem class provides blank space in a layout.
Definition qlayoutitem.h:57
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
Definition qstring.cpp:8870
\variable QStyleOptionHeaderV2::textElideMode
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
@ CT_PushButton
Definition qstyle.h:547
virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w=nullptr) const =0
Returns the size of the element described by the specified option and type, based on the provided con...
@ SH_MessageBox_CenterButtons
Definition qstyle.h:657
@ SH_MessageBox_TextInteractionFlags
Definition qstyle.h:655
@ SP_MessageBoxQuestion
Definition qstyle.h:729
@ SP_MessageBoxCritical
Definition qstyle.h:728
@ SP_MessageBoxInformation
Definition qstyle.h:726
@ SP_MessageBoxWarning
Definition qstyle.h:727
@ PM_MessageBoxIconSize
Definition qstyle.h:506
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
Definition qtextedit.h:27
void copyAvailable(bool b)
This signal is emitted when text is selected or de-selected in the text edit.
\reentrant
Definition qtextoption.h:18
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
static Q_CORE_EXPORT QVersionNumber fromString(QAnyStringView string, qsizetype *suffixIndex=nullptr)
QLayout * layout
Definition qwidget_p.h:651
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
void setWindowModality(Qt::WindowModality windowModality)
Definition qwidget.cpp:2799
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,...
Definition qwidget.cpp:7590
void setParent(QWidget *parent)
Sets the parent of the widget to parent, and resets the window flags.
Qt::WindowModality windowModality
which windows are blocked by the modal widget
Definition qwidget.h:104
void setSizePolicy(QSizePolicy)
QLayout * layout() const
Returns the layout manager that is installed on this widget, or \nullptr if no layout manager is inst...
QFontMetrics fontMetrics() const
Returns the font metrics for the widget's current font.
Definition qwidget.h:847
void setFocus()
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qwidget.h:423
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
virtual void setVisible(bool visible)
Definition qwidget.cpp:8255
void ensurePolished() const
Ensures that the widget and its children have been polished by QStyle (i.e., have a proper font and p...
QIcon windowIcon
the widget's icon
Definition qwidget.h:152
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9382
void setWindowTitle(const QString &)
Definition qwidget.cpp:6105
QStyle * style() const
Definition qwidget.cpp:2600
QFont font
the font currently set for the widget
Definition qwidget.h:133
QString windowTitle
the window title (caption)
Definition qwidget.h:151
QWidget * parentWidget() const
Returns the parent of this widget, or \nullptr if it does not have any parent widget.
Definition qwidget.h:904
\inmodule QtGui
Definition qwindow.h:63
QString text
QPushButton * button
[2]
auto signal
opt iconSize
QStyleOptionButton opt
else opt state
[0]
Combined button and popup list for selecting options.
Definition qcompare.h:63
CheckState
@ AlignVCenter
Definition qnamespace.h:155
@ AlignTop
Definition qnamespace.h:153
@ AlignLeft
Definition qnamespace.h:144
@ WA_StyleSheet
Definition qnamespace.h:372
@ WA_DontShowOnScreen
Definition qnamespace.h:383
@ WA_DeleteOnClose
Definition qnamespace.h:321
WindowModality
@ WindowModal
TextFormat
@ RichText
@ AutoText
@ NoFocus
Definition qnamespace.h:107
@ TextShowMnemonic
Definition qnamespace.h:173
Q_GUI_EXPORT bool mightBeRichText(QAnyStringView)
Returns true if the string text is likely to be rich text; otherwise returns false.
@ ControlModifier
@ MetaModifier
@ AltModifier
@ AA_DontUseNativeDialogs
Definition qnamespace.h:458
@ Dialog
Definition qnamespace.h:208
@ Sheet
Definition qnamespace.h:209
@ WindowTitleHint
Definition qnamespace.h:226
@ WindowSystemMenuHint
Definition qnamespace.h:227
static jboolean copy(JNIEnv *, jobject)
static jboolean selectAll(JNIEnv *, jobject)
FontHash * qt_app_fonts_hash()
#define Q_FALLTHROUGH()
QString qAppName()
#define qApp
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define qWarning
Definition qlogging.h:166
#define qFatal
Definition qlogging.h:168
return ret
Button
@ Old_No
@ Old_NoAll
@ Old_YesAll
@ Old_Ignore
@ Old_Retry
@ Old_Abort
@ Old_ButtonMask
@ Old_Yes
@ Old_Ok
@ NewButtonMask
@ Old_Cancel
static int oldButton(int button)
static QMessageDialogOptions::StandardIcon helperIcon(QMessageBox::Icon i)
static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
static QMessageBox::StandardButton newButton(int button)
static bool detectedCompat(int button0, int button1, int button2)
void qRequireVersion(int argc, char *argv[], QAnyStringView req)
DetailButtonLabel
@ ShowLabel
@ HideLabel
static QPlatformDialogHelper::StandardButtons helperStandardButtons(QMessageBox *q)
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLuint64 GLenum void * handle
GLuint64 key
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat f
GLint GLsizei width
GLuint GLsizei const GLchar * label
[43]
GLbitfield flags
GLuint GLsizei const GLchar * message
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLfloat GLfloat GLfloat GLfloat h
struct _cl_event * event
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
GLuint GLenum option
static QT_BEGIN_NAMESPACE qreal dpr(const QWindow *w)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define qUtf16Printable(string)
Definition qstring.h:1543
#define QStringLiteral(str)
#define sp
#define QT_CONFIG(feature)
#define tr(X)
#define Q_OBJECT
#define slots
#define emit
#define Q_UNUSED(x)
QT_BEGIN_NAMESPACE constexpr std::underlying_type_t< Enum > qToUnderlying(Enum e) noexcept
QT_BEGIN_NAMESPACE Q_CORE_EXPORT Q_DECL_CONST_FUNCTION const char * qVersion(void) Q_DECL_NOEXCEPT
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
const char className[16]
[1]
Definition qwizard.cpp:100
if(qFloatDistance(a, b)<(1<< 7))
[0]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QPushButton * pushButton
QObject::connect nullptr
QVBoxLayout * layout
QString title
[35]
QMessageBox msgBox
[0]
QMessageBox messageBox(this)
[2]
QGraphicsWidget * textEdit
myAction setIcon(SomeIcon)
widget render & pixmap
aWidget window() -> setWindowTitle("New Window Title")
[2]
insertRed setText("insert red text")
groupBox setLayout(vbox)
QMenu menu
[5]
QSizePolicy policy
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:962