Qt 4.8
qinputdialog.h
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 #ifndef QINPUTDIALOG_H
43 #define QINPUTDIALOG_H
44 
45 #include <QtGui/qdialog.h>
46 #include <QtCore/qstring.h>
47 #include <QtGui/qlineedit.h>
48 
50 
52 
53 QT_MODULE(Gui)
54 
55 #ifndef QT_NO_INPUTDIALOG
56 
58 
60 {
61  Q_OBJECT
63 // Q_ENUMS(InputMode InputDialogOption)
64  QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
65  QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
66  QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
67  QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
68  QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
69  QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
70  QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
71  QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
72  QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
73  QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
74  QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
75  QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
76  QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
77  QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
78  QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
79  QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
80  QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
81 
82 public:
84  NoButtons = 0x00000001,
85  UseListViewForComboBoxItems = 0x00000002
86  };
87 
88  Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
89 
90  enum InputMode {
93  DoubleInput
94  };
95 
96  QInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
97  ~QInputDialog();
98 
99  void setInputMode(InputMode mode);
100  InputMode inputMode() const;
101 
102  void setLabelText(const QString &text);
103  QString labelText() const;
104 
105  void setOption(InputDialogOption option, bool on = true);
106  bool testOption(InputDialogOption option) const;
107  void setOptions(InputDialogOptions options);
108  InputDialogOptions options() const;
109 
110  void setTextValue(const QString &text);
111  QString textValue() const;
112 
113  void setTextEchoMode(QLineEdit::EchoMode mode);
114  QLineEdit::EchoMode textEchoMode() const;
115 
116  void setComboBoxEditable(bool editable);
117  bool isComboBoxEditable() const;
118 
119  void setComboBoxItems(const QStringList &items);
120  QStringList comboBoxItems() const;
121 
122  void setIntValue(int value);
123  int intValue() const;
124 
125  void setIntMinimum(int min);
126  int intMinimum() const;
127 
128  void setIntMaximum(int max);
129  int intMaximum() const;
130 
131  void setIntRange(int min, int max);
132 
133  void setIntStep(int step);
134  int intStep() const;
135 
136  void setDoubleValue(double value);
137  double doubleValue() const;
138 
139  void setDoubleMinimum(double min);
140  double doubleMinimum() const;
141 
142  void setDoubleMaximum(double max);
143  double doubleMaximum() const;
144 
145  void setDoubleRange(double min, double max);
146 
147  void setDoubleDecimals(int decimals);
148  int doubleDecimals() const;
149 
150  void setOkButtonText(const QString &text);
151  QString okButtonText() const;
152 
153  void setCancelButtonText(const QString &text);
154  QString cancelButtonText() const;
155 
156 #ifdef Q_NO_USING_KEYWORD
157 #ifndef Q_QDOC
158  void open() { QDialog::open(); }
159 #endif
160 #else
161  using QDialog::open;
162 #endif
163  void open(QObject *receiver, const char *member);
164 
165  QSize minimumSizeHint() const;
166  QSize sizeHint() const;
167 
168  void setVisible(bool visible);
169 
170 #ifdef Q_QDOC
171  static QString getText(QWidget *parent, const QString &title, const QString &label,
173  const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
174  Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
175  static QString getItem(QWidget *parent, const QString &title, const QString &label,
176  const QStringList &items, int current = 0, bool editable = true,
177  bool *ok = 0, Qt::WindowFlags flags = 0,
178  Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
179 #else
180  static QString getText(QWidget *parent, const QString &title, const QString &label,
182  const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0);
183  static QString getItem(QWidget *parent, const QString &title, const QString &label,
184  const QStringList &items, int current = 0, bool editable = true,
185  bool *ok = 0, Qt::WindowFlags flags = 0);
186  static QString getText(QWidget *parent, const QString &title, const QString &label,
187  QLineEdit::EchoMode echo,
188  const QString &text, bool *ok, Qt::WindowFlags flags,
189  Qt::InputMethodHints inputMethodHints);
190  static QString getItem(QWidget *parent, const QString &title, const QString &label,
191  const QStringList &items, int current, bool editable,
192  bool *ok, Qt::WindowFlags flags,
193  Qt::InputMethodHints inputMethodHints);
194 #endif
195  static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
196  int minValue = -2147483647, int maxValue = 2147483647,
197  int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
198  static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
199  double minValue = -2147483647, double maxValue = 2147483647,
200  int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
201 
202  // obsolete
203  static int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
204  int minValue = -2147483647, int maxValue = 2147483647,
205  int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
206 
207 #ifdef QT3_SUPPORT
208  inline static QT3_SUPPORT QString getText(const QString &title, const QString &label,
210  const QString &text = QString(), bool *ok = 0,
211  QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
212  { return getText(parent, title, label, echo, text, ok, flags); }
213  inline static QT3_SUPPORT int getInteger(const QString &title, const QString &label, int value = 0,
214  int minValue = -2147483647, int maxValue = 2147483647,
215  int step = 1, bool *ok = 0,
216  QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
217  { return getInteger(parent, title, label, value, minValue, maxValue, step, ok, flags); }
218  inline static QT3_SUPPORT double getDouble(const QString &title, const QString &label, double value = 0,
219  double minValue = -2147483647, double maxValue = 2147483647,
220  int decimals = 1, bool *ok = 0,
221  QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
222  { return getDouble(parent, title, label, value, minValue, maxValue, decimals, ok, flags); }
223  inline static QT3_SUPPORT QString getItem(const QString &title, const QString &label, const QStringList &list,
224  int current = 0, bool editable = true, bool *ok = 0,
225  QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
226  { return getItem(parent, title, label, list, current, editable, ok, flags); }
227 #endif
228 
229 Q_SIGNALS:
230  // ### emit signals!
231  void textValueChanged(const QString &text);
232  void textValueSelected(const QString &text);
233  void intValueChanged(int value);
234  void intValueSelected(int value);
235  void doubleValueChanged(double value);
236  void doubleValueSelected(double value);
237 
238 
239 public:
240  void done(int result); // ### Qt 5: Make protected.
241 
242 private:
244  Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
245  Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&))
246 };
247 
248 Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
249 
250 #endif // QT_NO_INPUTDIALOG
251 
253 
255 
256 #endif // QINPUTDIALOG_H
static void getText(QString &text, QTextDocumentPrivate *priv, const QString &docText, int pos, int end)
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QDOC_PROPERTY(text)
Definition: qglobal.h:2503
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
#define Q_DECLARE_FLAGS(Flags, Enum)
The Q_DECLARE_FLAGS() macro expands to.
Definition: qglobal.h:2348
The QDialog class is the base class of dialog windows.
Definition: qdialog.h:56
QSize minimumSizeHint() const
Reimplemented Function
Definition: qdialog.cpp:1186
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
The QInputDialog class provides a simple convenience dialog to get a single value from the user...
Definition: qinputdialog.h:59
InputDialogOption
This enum specifies various options that affect the look and feel of an input dialog.
Definition: qinputdialog.h:83
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
#define Q_PRIVATE_SLOT(d, signature)
Definition: qobjectdefs.h:73
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
EchoMode
This enum type describes how a line edit should display its contents.
Definition: qlineedit.h:113
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
The Q_DECLARE_OPERATORS_FOR_FLAGS() macro declares global operator|() functions for Flags...
Definition: qglobal.h:2355
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QSize sizeHint() const
Reimplemented Function
Definition: qdialog.cpp:1160
#define Q_OBJECT
Definition: qobjectdefs.h:157
InputMode
This enum describes the different modes of input that can be selected for the dialog.
Definition: qinputdialog.h:90
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition: qdialog.cpp:617
The QModelIndex class is used to locate data in a data model.
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
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
#define QT_END_HEADER
Definition: qglobal.h:137
void setVisible(bool visible)
Reimplemented Function
Definition: qdialog.cpp:756
static int getInt(QDataStream &stream, Qt::Orientation o, bool pre43)
#define text
Definition: qobjectdefs.h:80