| 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"><!-- | 
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; } | 
|---|
| 9 | a:link { color: #004faf; text-decoration: none } | 
|---|
| 10 | a:visited { color: #672967; text-decoration: none } | 
|---|
| 11 | body { 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 Classes</font></a> | 
|---|
| 23 | | <a href="mainclasses.html"> | 
|---|
| 24 | <font color="#004faf">Main 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 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 <<a href="qinputdialog-h.html">qinputdialog.h</a>></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 QString & caption, const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 )</li> | 
|---|
| 42 | <li class=fn>int <a href="#getInteger"><b>getInteger</b></a> ( const QString & caption, const QString & label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool * ok = 0, QWidget * parent = 0, const char * name = 0 )</li> | 
|---|
| 43 | <li class=fn>double <a href="#getDouble"><b>getDouble</b></a> ( const QString & caption, const QString & label, double value = 0, double minValue = -2147483647, double maxValue = 2147483647, int decimals = 1, bool * ok = 0, QWidget * parent = 0, const char * name = 0 )</li> | 
|---|
| 44 | <li class=fn>QString <a href="#getItem"><b>getItem</b></a> ( const QString & caption, const QString & label, const QStringList & list, int current = 0, bool editable = TRUE, bool * ok = 0, QWidget * parent = 0, const char * name = 0 )</li> | 
|---|
| 45 | </ul> | 
|---|
| 46 | <hr><a name="details"></a><h2>Detailed Description</h2> | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | The 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 | 
|---|
| 53 | label 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 | 
|---|
| 56 | functions 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>, &ok, this ); | 
|---|
| 62 | if ( ok && !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 <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & label, double value = 0, double minValue = -2147483647, double maxValue = 2147483647, int decimals = 1, bool * ok = 0, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )<tt> [static]</tt> | 
|---|
| 73 | </h3> | 
|---|
| 74 | Static convenience function to get a floating point number from | 
|---|
| 75 | the user. <em>caption</em> is the text which is displayed in the title | 
|---|
| 76 | bar 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 | 
|---|
| 78 | floating point number that the line edit will be set to. <em>minValue</em> and <em>maxValue</em> are the minimum and maximum values the | 
|---|
| 79 | user may choose, and <em>decimals</em> is the maximum number of decimal | 
|---|
| 80 | places 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 | 
|---|
| 82 | pressed OK and to FALSE if the user pressed Cancel. The dialog's | 
|---|
| 83 | parent is <em>parent</em>; the dialog is called <em>name</em>. The dialog will | 
|---|
| 84 | be modal. | 
|---|
| 85 | <p> This function returns the floating point number which has been | 
|---|
| 86 | entered 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, &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 <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & label, int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool * ok = 0, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )<tt> [static]</tt> | 
|---|
| 102 | </h3> | 
|---|
| 103 | Static convenience function to get an integer input from the | 
|---|
| 104 | user. <em>caption</em> is the text which is displayed in the title bar | 
|---|
| 105 | of 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 | 
|---|
| 107 | integer which the spinbox will be set to.  <em>minValue</em> and <em>maxValue</em> are the minimum and maximum values the user may choose, | 
|---|
| 108 | and <em>step</em> is the amount by which the values change as the user | 
|---|
| 109 | presses 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 | 
|---|
| 111 | pressed OK and to FALSE if the user pressed Cancel. The dialog's | 
|---|
| 112 | parent is <em>parent</em>; the dialog is called <em>name</em>. The dialog will | 
|---|
| 113 | be 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 | &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 <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & label, const <a href="qstringlist.html">QStringList</a> & list, int current = 0, bool editable = TRUE, bool * ok = 0, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )<tt> [static]</tt> | 
|---|
| 130 | </h3> | 
|---|
| 131 | Static convenience function to let the user select an item from a | 
|---|
| 132 | string list. <em>caption</em> is the text which is displayed in the title | 
|---|
| 133 | bar of the dialog. <em>label</em> is the text which is shown to the user (it | 
|---|
| 134 | should say what should be entered). <em>list</em> is the | 
|---|
| 135 | string list which is inserted into the combobox, and <em>current</em> is the number | 
|---|
| 136 | of the item which should be the current item. If <em>editable</em> is TRUE | 
|---|
| 137 | the user can enter their own text; if <em>editable</em> is FALSE the user | 
|---|
| 138 | may 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 | 
|---|
| 140 | pressed OK and to FALSE if the user pressed Cancel. The dialog's | 
|---|
| 141 | parent is <em>parent</em>; the dialog is called <em>name</em>. The dialog will | 
|---|
| 142 | be 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 << "First" << "Second" << "Third" << "Fourth" << "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, &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 <a href="qstring.html">QString</a> & caption, const <a href="qstring.html">QString</a> & label, <a href="qlineedit.html#EchoMode-enum">QLineEdit::EchoMode</a> mode = QLineEdit::Normal, const <a href="qstring.html">QString</a> & text = QString::null, bool * ok = 0, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )<tt> [static]</tt> | 
|---|
| 161 | </h3> | 
|---|
| 162 | Static convenience function to get a string from the user. <em>caption</em> is the text which is displayed in the title bar of the | 
|---|
| 163 | dialog. <em>label</em> is the text which is shown to the user (it should | 
|---|
| 164 | say what should be entered). <em>text</em> is the default text which is | 
|---|
| 165 | placed in the line edit. The <em>mode</em> is the echo mode the line edit | 
|---|
| 166 | will use. If <em>ok</em> is not-null <em>*</em><em>ok</em> will be set to TRUE if the | 
|---|
| 167 | user pressed OK and to FALSE if the user pressed Cancel. The | 
|---|
| 168 | dialog's parent is <em>parent</em>; the dialog is called <em>name</em>. The | 
|---|
| 169 | dialog will be modal. | 
|---|
| 170 | <p> This function returns the text which has been entered in the line | 
|---|
| 171 | edit. 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>, &ok, this ); | 
|---|
| 178 | if ( ok && !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> | 
|---|
| 188 | This file is part of the <a href="index.html">Qt toolkit</a>. | 
|---|
| 189 | Copyright © 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 © 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> | 
|---|