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
qinputdialog.h
Go to the documentation of this file.
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 QINPUTDIALOG_H
5#define QINPUTDIALOG_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtCore/qstring.h>
9#include <QtWidgets/qlineedit.h>
10
11#include <QtWidgets/qdialog.h>
12
13QT_REQUIRE_CONFIG(inputdialog);
14
16
18
19class Q_WIDGETS_EXPORT QInputDialog : public QDialog
20{
22 Q_DECLARE_PRIVATE(QInputDialog)
23 QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
24 QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
25 QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
26 QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
27 QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
28 QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
29 QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
30 QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
31 QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
32 QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
33 QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
34 QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
35 QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
36 QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
37 QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
38 QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
39 QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
40 QDOC_PROPERTY(double doubleStep READ doubleStep WRITE setDoubleStep)
41
42public:
44 NoButtons = 0x00000001,
45 UseListViewForComboBoxItems = 0x00000002,
46 UsePlainTextEditForTextInput = 0x00000004
47 };
48
49 Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
50
51 enum InputMode {
54 DoubleInput
55 };
56
57 QInputDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
59
60 void setInputMode(InputMode mode);
61 InputMode inputMode() const;
62
63 void setLabelText(const QString &text);
64 QString labelText() const;
65
66 void setOption(InputDialogOption option, bool on = true);
67 bool testOption(InputDialogOption option) const;
68 void setOptions(InputDialogOptions options);
69 InputDialogOptions options() const;
70
71 void setTextValue(const QString &text);
72 QString textValue() const;
73
74 void setTextEchoMode(QLineEdit::EchoMode mode);
75 QLineEdit::EchoMode textEchoMode() const;
76
77 void setComboBoxEditable(bool editable);
78 bool isComboBoxEditable() const;
79
80 void setComboBoxItems(const QStringList &items);
81 QStringList comboBoxItems() const;
82
83 void setIntValue(int value);
84 int intValue() const;
85
86 void setIntMinimum(int min);
87 int intMinimum() const;
88
89 void setIntMaximum(int max);
90 int intMaximum() const;
91
92 void setIntRange(int min, int max);
93
94 void setIntStep(int step);
95 int intStep() const;
96
97 void setDoubleValue(double value);
98 double doubleValue() const;
99
100 void setDoubleMinimum(double min);
101 double doubleMinimum() const;
102
103 void setDoubleMaximum(double max);
104 double doubleMaximum() const;
105
106 void setDoubleRange(double min, double max);
107
108 void setDoubleDecimals(int decimals);
109 int doubleDecimals() const;
110
111 void setOkButtonText(const QString &text);
112 QString okButtonText() const;
113
114 void setCancelButtonText(const QString &text);
115 QString cancelButtonText() const;
116
117 using QDialog::open;
118 void open(QObject *receiver, const char *member);
119
120 QSize minimumSizeHint() const override;
121 QSize sizeHint() const override;
122
123 void setVisible(bool visible) override;
124
125 static QString getText(QWidget *parent, const QString &title, const QString &label,
127 const QString &text = QString(), bool *ok = nullptr,
128 Qt::WindowFlags flags = Qt::WindowFlags(),
129 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
130 static QString getMultiLineText(QWidget *parent, const QString &title, const QString &label,
131 const QString &text = QString(), bool *ok = nullptr,
132 Qt::WindowFlags flags = Qt::WindowFlags(),
133 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
134 static QString getItem(QWidget *parent, const QString &title, const QString &label,
135 const QStringList &items, int current = 0, bool editable = true,
136 bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
137 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
138
139 static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
140 int minValue = -2147483647, int maxValue = 2147483647,
141 int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
142
143 static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
144 double minValue = -2147483647, double maxValue = 2147483647,
145 int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
146 double step = 1);
147
148 void setDoubleStep(double step);
149 double doubleStep() const;
150
158
159public:
160 void done(int result) override;
161
162private:
163 Q_DISABLE_COPY(QInputDialog)
164};
165
166Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
167
169
170#endif // QINPUTDIALOG_H
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
virtual void open()
Definition qdialog.cpp:503
The QInputDialog class provides a simple convenience dialog to get a single value from the user.
void intValueChanged(int value)
This signal is emitted whenever the integer value changes in the dialog.
void intValueSelected(int value)
This signal is emitted whenever the user selects a integer value by accepting the dialog; for example...
void textValueSelected(const QString &text)
This signal is emitted whenever the user selects a text string by accepting the dialog; for example,...
void doubleValueChanged(double value)
This signal is emitted whenever the double value changes in the dialog.
void textValueChanged(const QString &text)
This signal is emitted whenever the text string changes in the dialog.
void doubleValueSelected(double value)
This signal is emitted whenever the user selects a double value by accepting the dialog; for example,...
EchoMode
This enum type describes how a line edit should display its contents.
Definition qlineedit.h:77
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QString text
Combined button and popup list for selecting options.
@ ImhNone
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLenum mode
GLuint GLsizei const GLchar * label
[43]
GLbitfield flags
GLuint64EXT * result
[6]
GLuint GLenum option
static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define QDOC_PROPERTY(text)
#define Q_SIGNALS
static int getInt(QDataStream &stream)
file open(QIODevice::ReadOnly)
QString title
[35]
QList< QTreeWidgetItem * > items