source: trunk/doc/html/qinputdialog.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 11.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/dialogs/qinputdialog.cpp:65 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QInputDialog Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QInputDialog Class Reference</h1>
33
34<p>The QInputDialog class provides a simple convenience dialog to get a single value from the user.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qinputdialog-h.html">qinputdialog.h</a>&gt;</tt>
37<p>Inherits <a href="qdialog.html">QDialog</a>.
38<p><a href="qinputdialog-members.html">List of all member functions.</a>
39<h2>Static Public Members</h2>
40<ul>
41<li class=fn>QString <a href="#getText"><b>getText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;label, QLineEdit::EchoMode&nbsp;mode = QLineEdit::Normal, const&nbsp;QString&nbsp;&amp;&nbsp;text = QString::null, bool&nbsp;*&nbsp;ok = 0, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
42<li class=fn>int <a href="#getInteger"><b>getInteger</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;label, int&nbsp;value = 0, int&nbsp;minValue = -2147483647, int&nbsp;maxValue = 2147483647, int&nbsp;step = 1, bool&nbsp;*&nbsp;ok = 0, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn>double <a href="#getDouble"><b>getDouble</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;label, double&nbsp;value = 0, double&nbsp;minValue = -2147483647, double&nbsp;maxValue = 2147483647, int&nbsp;decimals = 1, bool&nbsp;*&nbsp;ok = 0, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
44<li class=fn>QString <a href="#getItem"><b>getItem</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;caption, const&nbsp;QString&nbsp;&amp;&nbsp;label, const&nbsp;QStringList&nbsp;&amp;&nbsp;list, int&nbsp;current = 0, bool&nbsp;editable = TRUE, bool&nbsp;*&nbsp;ok = 0, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
45</ul>
46<hr><a name="details"></a><h2>Detailed Description</h2>
47
48
49The QInputDialog class provides a simple convenience dialog to get a single value from the user.
50
51
52<p> The input value can be a string, a number or an item from a list. A
53label must be set to tell the user what they should enter.
54<p> Four static convenience functions are provided:
55<a href="#getText">getText</a>(), <a href="#getInteger">getInteger</a>(), <a href="#getDouble">getDouble</a>() and <a href="#getItem">getItem</a>(). All the
56functions can be used in a similar way, for example:
57<pre>
58 bool ok;
59 <a href="qstring.html">QString</a> text = QInputDialog::<a href="#getText">getText</a>(
60 "MyApp 3000", "Enter your name:", QLineEdit::Normal,
61 <a href="qstring.html#QString-null">QString::null</a>, &amp;ok, this );
62 if ( ok &amp;&amp; !text.<a href="qstring.html#isEmpty">isEmpty</a>() ) {
63 // user entered something and pressed OK
64 } else {
65 // user entered nothing or pressed Cancel
66 }
67 </pre>
68
69<p> <center><img src="inputdialogs.png" alt="Input Dialogs"></center> <p>See also <a href="dialogs.html">Dialog Classes</a>.
70
71<hr><h2>Member Function Documentation</h2>
72<h3 class=fn>double <a name="getDouble"></a>QInputDialog::getDouble ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, double&nbsp;value = 0, double&nbsp;minValue = -2147483647, double&nbsp;maxValue = 2147483647, int&nbsp;decimals = 1, bool&nbsp;*&nbsp;ok = 0, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )<tt> [static]</tt>
73</h3>
74Static convenience function to get a floating point number from
75the user. <em>caption</em> is the text which is displayed in the title
76bar of the dialog. <em>label</em> is the text which is shown to the user
77(it should say what should be entered). <em>value</em> is the default
78floating point number that the line edit will be set to. <em>minValue</em> and <em>maxValue</em> are the minimum and maximum values the
79user may choose, and <em>decimals</em> is the maximum number of decimal
80places the number may have.
81<p> If <em>ok</em> is not-null <em>*</em><em>ok</em> will be set to TRUE if the user
82pressed OK and to FALSE if the user pressed Cancel. The dialog's
83parent is <em>parent</em>; the dialog is called <em>name</em>. The dialog will
84be modal.
85<p> This function returns the floating point number which has been
86entered by the user.
87<p> Use this static function like this:
88<p> <pre>
89 bool ok;
90 double res = QInputDialog::<a href="#getDouble">getDouble</a>(
91 "MyApp 3000", "Enter a decimal number:", 33.7, 0,
92 1000, 2, &amp;ok, this );
93 if ( ok ) {
94 // user entered something and pressed OK
95 } else {
96 // user pressed Cancel
97 }
98 </pre>
99
100
101<h3 class=fn>int <a name="getInteger"></a>QInputDialog::getInteger ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, int&nbsp;value = 0, int&nbsp;minValue = -2147483647, int&nbsp;maxValue = 2147483647, int&nbsp;step = 1, bool&nbsp;*&nbsp;ok = 0, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )<tt> [static]</tt>
102</h3>
103Static convenience function to get an integer input from the
104user. <em>caption</em> is the text which is displayed in the title bar
105of the dialog. <em>label</em> is the text which is shown to the user
106(it should say what should be entered). <em>value</em> is the default
107integer which the spinbox will be set to. <em>minValue</em> and <em>maxValue</em> are the minimum and maximum values the user may choose,
108and <em>step</em> is the amount by which the values change as the user
109presses the arrow buttons to increment or decrement the value.
110<p> If <em>ok</em> is not-null *<em>ok</em> will be set to TRUE if the user
111pressed OK and to FALSE if the user pressed Cancel. The dialog's
112parent is <em>parent</em>; the dialog is called <em>name</em>. The dialog will
113be modal.
114<p> This function returns the integer which has been entered by the user.
115<p> Use this static function like this:
116<p> <pre>
117 bool ok;
118 int res = QInputDialog::<a href="#getInteger">getInteger</a>(
119 "MyApp 3000", "Enter a number:", 22, 0, 1000, 2,
120 &amp;ok, this );
121 if ( ok ) {
122 // user entered something and pressed OK
123 } else {
124 // user pressed Cancel
125 }
126 </pre>
127
128
129<h3 class=fn><a href="qstring.html">QString</a> <a name="getItem"></a>QInputDialog::getItem ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;list, int&nbsp;current = 0, bool&nbsp;editable = TRUE, bool&nbsp;*&nbsp;ok = 0, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )<tt> [static]</tt>
130</h3>
131Static convenience function to let the user select an item from a
132string list. <em>caption</em> is the text which is displayed in the title
133bar of the dialog. <em>label</em> is the text which is shown to the user (it
134should say what should be entered). <em>list</em> is the
135string list which is inserted into the combobox, and <em>current</em> is the number
136of the item which should be the current item. If <em>editable</em> is TRUE
137the user can enter their own text; if <em>editable</em> is FALSE the user
138may only select one of the existing items.
139<p> If <em>ok</em> is not-null <em>*</em><em>ok</em> will be set to TRUE if the user
140pressed OK and to FALSE if the user pressed Cancel. The dialog's
141parent is <em>parent</em>; the dialog is called <em>name</em>. The dialog will
142be modal.
143<p> This function returns the text of the current item, or if <em>editable</em> is TRUE, the current text of the combobox.
144<p> Use this static function like this:
145<p> <pre>
146 <a href="qstringlist.html">QStringList</a> lst;
147 lst &lt;&lt; "First" &lt;&lt; "Second" &lt;&lt; "Third" &lt;&lt; "Fourth" &lt;&lt; "Fifth";
148 bool ok;
149 <a href="qstring.html">QString</a> res = QInputDialog::<a href="#getItem">getItem</a>(
150 "MyApp 3000", "Select an item:", lst, 1, TRUE, &amp;ok,
151 this );
152 if ( ok ) {
153 // user selected an item and pressed OK
154 } else {
155 // user pressed Cancel
156 }
157 </pre>
158
159
160<h3 class=fn><a href="qstring.html">QString</a> <a name="getText"></a>QInputDialog::getText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;caption, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label, <a href="qlineedit.html#EchoMode-enum">QLineEdit::EchoMode</a>&nbsp;mode = QLineEdit::Normal, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text = QString::null, bool&nbsp;*&nbsp;ok = 0, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )<tt> [static]</tt>
161</h3>
162Static convenience function to get a string from the user. <em>caption</em> is the text which is displayed in the title bar of the
163dialog. <em>label</em> is the text which is shown to the user (it should
164say what should be entered). <em>text</em> is the default text which is
165placed in the line edit. The <em>mode</em> is the echo mode the line edit
166will use. If <em>ok</em> is not-null <em>*</em><em>ok</em> will be set to TRUE if the
167user pressed OK and to FALSE if the user pressed Cancel. The
168dialog's parent is <em>parent</em>; the dialog is called <em>name</em>. The
169dialog will be modal.
170<p> This function returns the text which has been entered in the line
171edit. It will not return an empty string.
172<p> Use this static function like this:
173<p> <pre>
174 bool ok;
175 <a href="qstring.html">QString</a> text = QInputDialog::<a href="#getText">getText</a>(
176 "MyApp 3000", "Enter your name:", QLineEdit::Normal,
177 <a href="qstring.html#QString-null">QString::null</a>, &amp;ok, this );
178 if ( ok &amp;&amp; !text.<a href="qstring.html#isEmpty">isEmpty</a>() ) {
179 // user entered something and pressed OK
180 } else {
181 // user entered nothing or pressed Cancel
182 }
183 </pre>
184
185
186<!-- eof -->
187<hr><p>
188This file is part of the <a href="index.html">Qt toolkit</a>.
189Copyright &copy; 1995-2007
190<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
191<table width=100% cellspacing=0 border=0><tr>
192<td>Copyright &copy; 2007
193<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
194<td align=right><div align=right>Qt 3.3.8</div>
195</table></div></address></body>
196</html>
Note: See TracBrowser for help on using the repository browser.