Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtWidgets/qmessagebox.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QMESSAGEBOX_H
0005 #define QMESSAGEBOX_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qdialog.h>
0009 #include <QtWidgets/qdialogbuttonbox.h>
0010 
0011 QT_REQUIRE_CONFIG(messagebox);
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 class QAnyStringView;
0016 class QLabel;
0017 class QMessageBoxPrivate;
0018 class QAbstractButton;
0019 class QCheckBox;
0020 
0021 class Q_WIDGETS_EXPORT QMessageBox : public QDialog
0022 {
0023     Q_OBJECT
0024     Q_PROPERTY(QString text READ text WRITE setText)
0025     Q_PROPERTY(Icon icon READ icon WRITE setIcon)
0026     Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
0027     Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
0028     Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
0029 #if QT_CONFIG(textedit)
0030     Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText)
0031 #endif
0032     Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText)
0033     Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags
0034                WRITE setTextInteractionFlags)
0035     Q_PROPERTY(Options options READ options WRITE setOptions)
0036 public:
0037     // Keep in sync with MessageBoxOption in qplatformdialoghelper.h
0038     enum class Option {
0039         DontUseNativeDialog = 0x00000001
0040     };
0041     Q_FLAG(Option)
0042 
0043     enum Icon {
0044         // keep this in sync with QMessageDialogOptions::StandardIcon
0045         NoIcon = 0,
0046         Information = 1,
0047         Warning = 2,
0048         Critical = 3,
0049         Question = 4
0050     };
0051     Q_ENUM(Icon)
0052 
0053     enum ButtonRole {
0054         // keep this in sync with QDialogButtonBox::ButtonRole and QPlatformDialogHelper::ButtonRole
0055         InvalidRole = -1,
0056         AcceptRole,
0057         RejectRole,
0058         DestructiveRole,
0059         ActionRole,
0060         HelpRole,
0061         YesRole,
0062         NoRole,
0063         ResetRole,
0064         ApplyRole,
0065 
0066         NRoles
0067     };
0068     Q_ENUM(ButtonRole)
0069 
0070     enum StandardButton {
0071         // keep this in sync with QDialogButtonBox::StandardButton and QPlatformDialogHelper::StandardButton
0072         NoButton           = 0x00000000,
0073         Ok                 = 0x00000400,
0074         Save               = 0x00000800,
0075         SaveAll            = 0x00001000,
0076         Open               = 0x00002000,
0077         Yes                = 0x00004000,
0078         YesToAll           = 0x00008000,
0079         No                 = 0x00010000,
0080         NoToAll            = 0x00020000,
0081         Abort              = 0x00040000,
0082         Retry              = 0x00080000,
0083         Ignore             = 0x00100000,
0084         Close              = 0x00200000,
0085         Cancel             = 0x00400000,
0086         Discard            = 0x00800000,
0087         Help               = 0x01000000,
0088         Apply              = 0x02000000,
0089         Reset              = 0x04000000,
0090         RestoreDefaults    = 0x08000000,
0091 
0092         FirstButton        = Ok,                // internal
0093         LastButton         = RestoreDefaults,   // internal
0094 
0095         YesAll             = YesToAll,          // obsolete
0096         NoAll              = NoToAll,           // obsolete
0097 
0098         Default            = 0x00000100,        // obsolete
0099         Escape             = 0x00000200,        // obsolete
0100         FlagMask           = 0x00000300,        // obsolete
0101         ButtonMask         = ~FlagMask          // obsolete
0102     };
0103     Q_ENUM(StandardButton)
0104 
0105 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0106     typedef StandardButton Button;
0107 #endif
0108     Q_DECLARE_FLAGS(Options, Option)
0109     Q_DECLARE_FLAGS(StandardButtons, StandardButton)
0110 
0111     Q_FLAG(StandardButtons)
0112 
0113     explicit QMessageBox(QWidget *parent = nullptr);
0114     QMessageBox(Icon icon, const QString &title, const QString &text,
0115                 StandardButtons buttons = NoButton, QWidget *parent = nullptr,
0116                 Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
0117     ~QMessageBox();
0118 
0119     void addButton(QAbstractButton *button, ButtonRole role);
0120     QPushButton *addButton(const QString &text, ButtonRole role);
0121     QPushButton *addButton(StandardButton button);
0122     void removeButton(QAbstractButton *button);
0123 
0124     using QDialog::open;
0125     void open(QObject *receiver, const char *member);
0126 
0127     QList<QAbstractButton *> buttons() const;
0128     ButtonRole buttonRole(QAbstractButton *button) const;
0129 
0130     void setStandardButtons(StandardButtons buttons);
0131     StandardButtons standardButtons() const;
0132     StandardButton standardButton(QAbstractButton *button) const;
0133     QAbstractButton *button(StandardButton which) const;
0134 
0135     QPushButton *defaultButton() const;
0136     void setDefaultButton(QPushButton *button);
0137     void setDefaultButton(StandardButton button);
0138 
0139     QAbstractButton *escapeButton() const;
0140     void setEscapeButton(QAbstractButton *button);
0141     void setEscapeButton(StandardButton button);
0142 
0143     QAbstractButton *clickedButton() const;
0144 
0145     QString text() const;
0146     void setText(const QString &text);
0147 
0148     Icon icon() const;
0149     void setIcon(Icon);
0150 
0151     QPixmap iconPixmap() const;
0152     void setIconPixmap(const QPixmap &pixmap);
0153 
0154     Qt::TextFormat textFormat() const;
0155     void setTextFormat(Qt::TextFormat format);
0156 
0157     void setTextInteractionFlags(Qt::TextInteractionFlags flags);
0158     Qt::TextInteractionFlags textInteractionFlags() const;
0159 
0160     void setCheckBox(QCheckBox *cb);
0161     QCheckBox* checkBox() const;
0162 
0163     void setOption(Option option, bool on = true);
0164     bool testOption(Option option) const;
0165     void setOptions(Options options);
0166     Options options() const;
0167 
0168     static StandardButton information(QWidget *parent, const QString &title,
0169          const QString &text, StandardButtons buttons = Ok,
0170          StandardButton defaultButton = NoButton);
0171 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) // needed as long as we have int overloads
0172     inline static StandardButton information(QWidget *parent, const QString &title,
0173                                   const QString& text,
0174                                   StandardButton button0, StandardButton button1 = NoButton)
0175     { return information(parent, title, text, StandardButtons(button0), button1); }
0176 #endif
0177 
0178     static StandardButton question(QWidget *parent, const QString &title,
0179          const QString &text, StandardButtons buttons = StandardButtons(Yes | No),
0180          StandardButton defaultButton = NoButton);
0181 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0182     inline static int question(QWidget *parent, const QString &title,
0183                                const QString& text,
0184                                StandardButton button0, StandardButton button1)
0185     { return question(parent, title, text, StandardButtons(button0), button1); }
0186 #endif
0187 
0188     static StandardButton warning(QWidget *parent, const QString &title,
0189          const QString &text, StandardButtons buttons = Ok,
0190          StandardButton defaultButton = NoButton);
0191 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0192     inline static int warning(QWidget *parent, const QString &title,
0193                               const QString& text,
0194                               StandardButton button0, StandardButton button1)
0195     { return warning(parent, title, text, StandardButtons(button0), button1); }
0196 #endif
0197 
0198     static StandardButton critical(QWidget *parent, const QString &title,
0199          const QString &text, StandardButtons buttons = Ok,
0200          StandardButton defaultButton = NoButton);
0201 #if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
0202     inline static int critical(QWidget *parent, const QString &title,
0203                                const QString& text,
0204                                StandardButton button0, StandardButton button1)
0205     { return critical(parent, title, text, StandardButtons(button0), button1); }
0206 #endif
0207 
0208     static void about(QWidget *parent, const QString &title, const QString &text);
0209     static void aboutQt(QWidget *parent, const QString &title = QString());
0210 
0211 #if QT_DEPRECATED_SINCE(6,2)
0212     // the following functions are obsolete:
0213     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0214     QMessageBox(const QString &title, const QString &text, Icon icon,
0215                   int button0, int button1, int button2,
0216                   QWidget *parent = nullptr,
0217                   Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
0218 
0219     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0220     static int information(QWidget *parent, const QString &title,
0221                            const QString& text,
0222                            int button0, int button1 = 0, int button2 = 0);
0223     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0224     static int information(QWidget *parent, const QString &title,
0225                            const QString& text,
0226                            const QString& button0Text,
0227                            const QString& button1Text = QString(),
0228                            const QString& button2Text = QString(),
0229                            int defaultButtonNumber = 0,
0230                            int escapeButtonNumber = -1);
0231 
0232     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0233     static int question(QWidget *parent, const QString &title,
0234                         const QString& text,
0235                         int button0, int button1 = 0, int button2 = 0);
0236     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0237     static int question(QWidget *parent, const QString &title,
0238                         const QString& text,
0239                         const QString& button0Text,
0240                         const QString& button1Text = QString(),
0241                         const QString& button2Text = QString(),
0242                         int defaultButtonNumber = 0,
0243                         int escapeButtonNumber = -1);
0244 
0245     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0246     static int warning(QWidget *parent, const QString &title,
0247                        const QString& text,
0248                        int button0, int button1, int button2 = 0);
0249     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0250     static int warning(QWidget *parent, const QString &title,
0251                        const QString& text,
0252                        const QString& button0Text,
0253                        const QString& button1Text = QString(),
0254                        const QString& button2Text = QString(),
0255                        int defaultButtonNumber = 0,
0256                        int escapeButtonNumber = -1);
0257 
0258     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0259     static int critical(QWidget *parent, const QString &title,
0260                         const QString& text,
0261                         int button0, int button1, int button2 = 0);
0262     QT_DEPRECATED_VERSION_X_6_2("Use the overload taking StandardButtons instead.")
0263     static int critical(QWidget *parent, const QString &title,
0264                         const QString& text,
0265                         const QString& button0Text,
0266                         const QString& button1Text = QString(),
0267                         const QString& button2Text = QString(),
0268                         int defaultButtonNumber = 0,
0269                         int escapeButtonNumber = -1);
0270 
0271     QT_DEPRECATED_VERSION_X_6_2("Use button() and QPushButton::text() instead.")
0272     QString buttonText(int button) const;
0273     QT_DEPRECATED_VERSION_X_6_2("Use addButton() instead.")
0274     void setButtonText(int button, const QString &text);
0275 #endif
0276 
0277     QString informativeText() const;
0278     void setInformativeText(const QString &text);
0279 
0280 #if QT_CONFIG(textedit)
0281     QString detailedText() const;
0282     void setDetailedText(const QString &text);
0283 #endif
0284 
0285     void setWindowTitle(const QString &title);
0286     void setWindowModality(Qt::WindowModality windowModality);
0287 
0288 #if QT_DEPRECATED_SINCE(6,2)
0289     QT_DEPRECATED_VERSION_X_6_2("Use QStyle::standardIcon() instead.")
0290     static QPixmap standardIcon(Icon icon);
0291 #endif
0292 
0293 Q_SIGNALS:
0294     void buttonClicked(QAbstractButton *button);
0295 
0296 #ifdef Q_QDOC
0297 public Q_SLOTS:
0298     int exec() override;
0299 #endif
0300 
0301 protected:
0302     bool event(QEvent *e) override;
0303     void resizeEvent(QResizeEvent *event) override;
0304     void showEvent(QShowEvent *event) override;
0305     void closeEvent(QCloseEvent *event) override;
0306     void keyPressEvent(QKeyEvent *event) override;
0307     void changeEvent(QEvent *event) override;
0308 
0309 private:
0310     Q_DISABLE_COPY(QMessageBox)
0311     Q_DECLARE_PRIVATE(QMessageBox)
0312 };
0313 
0314 Q_DECLARE_OPERATORS_FOR_FLAGS(QMessageBox::StandardButtons)
0315 
0316 Q_WIDGETS_EXPORT void qRequireVersion(int argc, char *argv[], QAnyStringView req);
0317 
0318 #define QT_REQUIRE_VERSION(argc, argv, str) qRequireVersion(argc, argv, str);
0319 
0320 QT_END_NAMESPACE
0321 
0322 #endif // QMESSAGEBOX_H