1QInputDialog(3qt) QInputDialog(3qt)
2
3
4
6 QInputDialog - Simple convenience dialog to get a single value from the
7 user
8
10 #include <qinputdialog.h>
11
12 Inherits QDialog.
13
14 Static Public Members
15 <li class=fn>QString getText ( const QString & caption, const QString &
16 label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString &
17 text = QString::null, bool * ok = 0, QWidget * parent = 0, const char *
18 name = 0 ) <li class=fn>int getInteger ( const QString & caption, const
19 QString & label, int value = 0, int minValue = -2147483647, int
20 maxValue = 2147483647, int step = 1, bool * ok = 0, QWidget * parent =
21 0, const char * name = 0 ) <li class=fn>double getDouble ( const
22 QString & caption, const QString & label, double value = 0, double
23 minValue = -2147483647, double maxValue = 2147483647, int decimals = 1,
24 bool * ok = 0, QWidget * parent = 0, const char * name = 0 ) <li
25 class=fn>QString getItem ( const QString & caption, const QString &
26 label, const QStringList & list, int current = 0, bool editable = TRUE,
27 bool * ok = 0, QWidget * parent = 0, const char * name = 0 )
28
30 The QInputDialog class provides a simple convenience dialog to get a
31 single value from the user.
32
33 The input value can be a string, a number or an item from a list. A
34 label must be set to tell the user what they should enter.
35
36 Four static convenience functions are provided: getText(),
37 getInteger(), getDouble() and getItem(). All the functions can be used
38 in a similar way, for example:
39
40 bool ok;
41 QString text = QInputDialog::getText(
42 "MyApp 3000", "Enter your name:", QLineEdit::Normal,
43 QString::null, &ok, this );
44 if ( ok && !text.isEmpty() ) {
45 // user entered something and pressed OK
46 } else {
47 // user entered nothing or pressed Cancel
48 }
49
50 <center>
51 [Image Omitted]
52
53 </center>
54
55 See also Dialog Classes.
56
59 label, double value = 0, double minValue = -2147483647, double maxValue
60 = 2147483647, int decimals = 1, bool * ok = 0, QWidget * parent = 0,
61 const char * name = 0 ) [static]
62 Static convenience function to get a floating point number from the
63 user. caption is the text which is displayed in the title bar of the
64 dialog. label is the text which is shown to the user (it should say
65 what should be entered). value is the default floating point number
66 that the line edit will be set to. minValue and maxValue are the
67 minimum and maximum values the user may choose, and decimals is the
68 maximum number of decimal places the number may have.
69
70 If ok is not-null *ok will be set to TRUE if the user pressed OK and to
71 FALSE if the user pressed Cancel. The dialog's parent is parent; the
72 dialog is called name. The dialog will be modal.
73
74 This function returns the floating point number which has been entered
75 by the user.
76
77 Use this static function like this:
78
79 bool ok;
80 double res = QInputDialog::getDouble(
81 "MyApp 3000", "Enter a decimal number:", 33.7, 0,
82 1000, 2, &ok, this );
83 if ( ok ) {
84 // user entered something and pressed OK
85 } else {
86 // user pressed Cancel
87 }
88
90 int value = 0, int minValue = -2147483647, int maxValue = 2147483647,
91 int step = 1, bool * ok = 0, QWidget * parent = 0, const char * name =
92 0 ) [static]
93 Static convenience function to get an integer input from the user.
94 caption is the text which is displayed in the title bar of the dialog.
95 label is the text which is shown to the user (it should say what should
96 be entered). value is the default integer which the spinbox will be set
97 to. minValue and maxValue are the minimum and maximum values the user
98 may choose, and step is the amount by which the values change as the
99 user presses the arrow buttons to increment or decrement the value.
100
101 If ok is not-null *ok will be set to TRUE if the user pressed OK and to
102 FALSE if the user pressed Cancel. The dialog's parent is parent; the
103 dialog is called name. The dialog will be modal.
104
105 This function returns the integer which has been entered by the user.
106
107 Use this static function like this:
108
109 bool ok;
110 int res = QInputDialog::getInteger(
111 "MyApp 3000", "Enter a number:", 22, 0, 1000, 2,
112 &ok, this );
113 if ( ok ) {
114 // user entered something and pressed OK
115 } else {
116 // user pressed Cancel
117 }
118
120 label, const QStringList & list, int current = 0, bool editable = TRUE,
121 bool * ok = 0, QWidget * parent = 0, const char * name = 0 ) [static]
122 Static convenience function to let the user select an item from a
123 string list. caption is the text which is displayed in the title bar of
124 the dialog. label is the text which is shown to the user (it should say
125 what should be entered). list is the string list which is inserted into
126 the combobox, and current is the number of the item which should be the
127 current item. If editable is TRUE the user can enter their own text; if
128 editable is FALSE the user may only select one of the existing items.
129
130 If ok is not-null *ok will be set to TRUE if the user pressed OK and to
131 FALSE if the user pressed Cancel. The dialog's parent is parent; the
132 dialog is called name. The dialog will be modal.
133
134 This function returns the text of the current item, or if editable is
135 TRUE, the current text of the combobox.
136
137 Use this static function like this:
138
139 QStringList lst;
140 lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
141 bool ok;
142 QString res = QInputDialog::getItem(
143 "MyApp 3000", "Select an item:", lst, 1, TRUE, &ok,
144 this );
145 if ( ok ) {
146 // user selected an item and pressed OK
147 } else {
148 // user pressed Cancel
149 }
150
152 label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString &
153 text = QString::null, bool * ok = 0, QWidget * parent = 0, const char *
154 name = 0 ) [static]
155 Static convenience function to get a string from the user. caption is
156 the text which is displayed in the title bar of the dialog. label is
157 the text which is shown to the user (it should say what should be
158 entered). text is the default text which is placed in the line edit.
159 The mode is the echo mode the line edit will use. If ok is not-null *ok
160 will be set to TRUE if the user pressed OK and to FALSE if the user
161 pressed Cancel. The dialog's parent is parent; the dialog is called
162 name. The dialog will be modal.
163
164 This function returns the text which has been entered in the line edit.
165 It will not return an empty string.
166
167 Use this static function like this:
168
169 bool ok;
170 QString text = QInputDialog::getText(
171 "MyApp 3000", "Enter your name:", QLineEdit::Normal,
172 QString::null, &ok, this );
173 if ( ok && !text.isEmpty() ) {
174 // user entered something and pressed OK
175 } else {
176 // user entered nothing or pressed Cancel
177 }
178
179
181 http://doc.trolltech.com/qinputdialog.html
182 http://www.trolltech.com/faq/tech.html
183
185 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
186 license file included in the distribution for a complete license
187 statement.
188
190 Generated automatically from the source code.
191
193 If you find a bug in Qt, please report it as described in
194 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
195 help you. Thank you.
196
197 The definitive Qt documentation is provided in HTML format; it is
198 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
199 web browser. This man page is provided as a convenience for those users
200 who prefer man pages, although this format is not officially supported
201 by Trolltech.
202
203 If you find errors in this manual page, please report them to qt-
204 bugs@trolltech.com. Please include the name of the manual page
205 (qinputdialog.3qt) and the Qt version (3.3.8).
206
207
208
209Trolltech AS 2 February 2007 QInputDialog(3qt)