1// Copyright (C) 2016 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#ifndef QDIALOG_H
5#define QDIALOG_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qwidget.h>
9
10QT_REQUIRE_CONFIG(dialog);
11
12QT_BEGIN_NAMESPACE
13
14
15class QPushButton;
16class QDialogPrivate;
17
18class Q_WIDGETS_EXPORT QDialog : public QWidget
19{
20 Q_OBJECT
21 friend class QPushButton;
22
23 Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
24 Q_PROPERTY(bool modal READ isModal WRITE setModal)
25
26public:
27 explicit QDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
28 ~QDialog();
29
30 enum DialogCode { Rejected, Accepted };
31 Q_ENUM(DialogCode)
32
33 int result() const;
34
35 void setVisible(bool visible) override;
36
37 QSize sizeHint() const override;
38 QSize minimumSizeHint() const override;
39
40 void setSizeGripEnabled(bool);
41 bool isSizeGripEnabled() const;
42
43 void setModal(bool modal);
44 void setResult(int r);
45
46Q_SIGNALS:
47 void finished(int result);
48 void accepted();
49 void rejected();
50
51public Q_SLOTS:
52 virtual void open();
53 virtual int exec();
54 virtual void done(int);
55 virtual void accept();
56 virtual void reject();
57
58protected:
59 QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
60
61 void keyPressEvent(QKeyEvent *) override;
62 void closeEvent(QCloseEvent *) override;
63 void showEvent(QShowEvent *) override;
64 void resizeEvent(QResizeEvent *) override;
65#ifndef QT_NO_CONTEXTMENU
66 void contextMenuEvent(QContextMenuEvent *) override;
67#endif
68 bool eventFilter(QObject *, QEvent *) override;
69 void adjustPosition(QWidget*);
70private:
71 Q_DECLARE_PRIVATE(QDialog)
72 Q_DISABLE_COPY(QDialog)
73};
74
75QT_END_NAMESPACE
76
77#endif // QDIALOG_H
78

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtbase/src/widgets/dialogs/qdialog.h