~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qinputdialog.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/dialogs/qinputdialog.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QInputDialog Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QInputDialog Class Reference</h1>
 
21
<p>The QInputDialog class provides a simple convenience dialog to get a single value from the user. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QInputDialog&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qdialog.html">QDialog</a>.</p>
 
24
<ul>
 
25
<li><a href="qinputdialog-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qinputdialog-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="static-public-members"></a>
 
29
<h3>Static Public Members</h3>
 
30
<ul>
 
31
<li><div class="fn"/>double <b><a href="qinputdialog.html#getDouble">getDouble</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, double <i>value</i> = 0, double <i>minValue</i> = -2147483647, double <i>maxValue</i> = 2147483647, int <i>decimals</i> = 1, bool * <i>ok</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
32
<li><div class="fn"/>int <b><a href="qinputdialog.html#getInteger">getInteger</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, int <i>value</i> = 0, int <i>minValue</i> = -2147483647, int <i>maxValue</i> = 2147483647, int <i>step</i> = 1, bool * <i>ok</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
33
<li><div class="fn"/>QString <b><a href="qinputdialog.html#getItem">getItem</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, const QStringList &amp; <i>list</i>, int <i>current</i> = 0, bool <i>editable</i> = true, bool * <i>ok</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
34
<li><div class="fn"/>QString <b><a href="qinputdialog.html#getText">getText</a></b> ( QWidget * <i>parent</i>, const QString &amp; <i>title</i>, const QString &amp; <i>label</i>, QLineEdit::EchoMode <i>mode</i> = QLineEdit::Normal, const QString &amp; <i>text</i> = QString(), bool * <i>ok</i> = 0, Qt::WFlags <i>f</i> = 0 )</li>
 
35
</ul>
 
36
<ul>
 
37
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
 
38
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
39
</ul>
 
40
<h3>Additional Inherited Members</h3>
 
41
<ul>
 
42
<li><div class="fn"/>2 properties inherited from <a href="qdialog.html#properties">QDialog</a></li>
 
43
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
 
44
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
45
<li><div class="fn"/>9 public functions inherited from <a href="qdialog.html#public-functions">QDialog</a></li>
 
46
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
 
47
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
48
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
 
49
<li><div class="fn"/>5 public slots inherited from <a href="qdialog.html#public-slots">QDialog</a></li>
 
50
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
 
51
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
52
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
 
53
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
54
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
 
55
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
56
</ul>
 
57
<a name="details"></a>
 
58
<hr />
 
59
<h2>Detailed Description</h2>
 
60
<p>The QInputDialog class provides a simple convenience dialog to get a single value from the user.</p>
 
61
<p>The input value can be a string, a number or an item from a list. A label must be set to tell the user what they should enter.</p>
 
62
<p>Four static convenience functions are provided: <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getInteger">getInteger</a>(), <a href="qinputdialog.html#getDouble">getDouble</a>() and <a href="qinputdialog.html#getItem">getItem</a>(). All the functions can be used in a similar way, for example:</p>
 
63
<pre>&nbsp;       bool ok;
 
64
        QString text = QInputDialog::getText(this, tr(&quot;QInputDialog::getText()&quot;),
 
65
                                             tr(&quot;User name:&quot;), QLineEdit::Normal,
 
66
                                             QDir::home().dirName(), &amp;ok);
 
67
        if (ok &amp;&amp; !text.isEmpty())
 
68
            textLabel-&gt;setText(text);</pre>
 
69
<p>The <tt>ok</tt> variable is set to true if the user clicks <b>OK</b>; otherwise it is set to false.</p>
 
70
<center><img src="images/inputdialogs.png" alt="Input Dialogs" /></center><p>The <a href="dialogs-standarddialogs.html">Standard Dialogs</a> example shows how to use QInputDialog as well as other built-in Qt dialogs.</p>
 
71
<p>See also <a href="qmessagebox.html">QMessageBox</a>.</p>
 
72
<hr />
 
73
<h2>Member Function Documentation</h2>
 
74
<h3 class="fn"><a name="getDouble"></a>double QInputDialog::getDouble ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, double <i>value</i> = 0, double <i>minValue</i> = -2147483647, double <i>maxValue</i> = 2147483647, int <i>decimals</i> = 1, bool * <i>ok</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
75
<p>Static convenience function to get a floating point number from the user. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>value</i> is the default floating point number that the line edit will be set to. <i>minValue</i> and <i>maxValue</i> are the minimum and maximum values the user may choose, and <i>decimals</i> is the maximum number of decimal places the number may have.</p>
 
76
<p>If <i>ok</i> is non-null, *<i>ok</i> will be set to true if the user pressed OK and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
 
77
<p>This function returns the floating point number which has been entered by the user.</p>
 
78
<p>Use this static function like this:</p>
 
79
<pre>&nbsp;       bool ok;
 
80
        double d = QInputDialog::getDouble(this, tr(&quot;QInputDialog::getDouble()&quot;),
 
81
                                           tr(&quot;Amount:&quot;), 37.56, -10000, 10000, 2, &amp;ok);
 
82
        if (ok)
 
83
            doubleLabel-&gt;setText(QString(&quot;$%1&quot;).arg(d));</pre>
 
84
<p>See also <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getInteger">getInteger</a>(), and <a href="qinputdialog.html#getItem">getItem</a>().</p>
 
85
<h3 class="fn"><a name="getInteger"></a>int QInputDialog::getInteger ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, int <i>value</i> = 0, int <i>minValue</i> = -2147483647, int <i>maxValue</i> = 2147483647, int <i>step</i> = 1, bool * <i>ok</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
86
<p>Static convenience function to get an integer input from the user. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>value</i> is the default integer which the spinbox will be set to. <i>minValue</i> and <i>maxValue</i> are the minimum and maximum values the user may choose, and <i>step</i> is the amount by which the values change as the user presses the arrow buttons to increment or decrement the value.</p>
 
87
<p>If <i>ok</i> is non-null *<i>ok</i> will be set to true if the user pressed <b>OK</b> and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
 
88
<p>This function returns the integer which has been entered by the user.</p>
 
89
<p>Use this static function like this:</p>
 
90
<pre>&nbsp;       bool ok;
 
91
        int i = QInputDialog::getInteger(this, tr(&quot;QInputDialog::getInteger()&quot;),
 
92
                                         tr(&quot;Percentage:&quot;), 25, 0, 100, 1, &amp;ok);
 
93
        if (ok)
 
94
            integerLabel-&gt;setText(tr(&quot;%1%&quot;).arg(i));</pre>
 
95
<p>See also <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getDouble">getDouble</a>(), and <a href="qinputdialog.html#getItem">getItem</a>().</p>
 
96
<h3 class="fn"><a name="getItem"></a><a href="qstring.html">QString</a> QInputDialog::getItem ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, const <a href="qstringlist.html">QStringList</a> &amp; <i>list</i>, int <i>current</i> = 0, bool <i>editable</i> = true, bool * <i>ok</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
97
<p>Static convenience function to let the user select an item from a string list. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>list</i> is the string list which is inserted into the combobox, and <i>current</i> is the number of the item which should be the current item. If <i>editable</i> is true the user can enter their own text; if <i>editable</i> is false the user may only select one of the existing items.</p>
 
98
<p>If <i>ok</i> is non-null <i>*a</i> ok will be set to true if the user pressed OK and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
 
99
<p>This function returns the text of the current item, or if <i>editable</i> is true, the current text of the combobox.</p>
 
100
<p>Use this static function like this:</p>
 
101
<pre>&nbsp;       QStringList items;
 
102
        items &lt;&lt; tr(&quot;Spring&quot;) &lt;&lt; tr(&quot;Summer&quot;) &lt;&lt; tr(&quot;Fall&quot;) &lt;&lt; tr(&quot;Winter&quot;);
 
103
 
 
104
        bool ok;
 
105
        QString item = QInputDialog::getItem(this, tr(&quot;QInputDialog::getItem()&quot;),
 
106
                                             tr(&quot;Season:&quot;), items, 0, false, &amp;ok);
 
107
        if (ok &amp;&amp; !item.isEmpty())
 
108
            itemLabel-&gt;setText(item);</pre>
 
109
<p>See also <a href="qinputdialog.html#getText">getText</a>(), <a href="qinputdialog.html#getInteger">getInteger</a>(), and <a href="qinputdialog.html#getDouble">getDouble</a>().</p>
 
110
<h3 class="fn"><a name="getText"></a><a href="qstring.html">QString</a> QInputDialog::getText ( <a href="qwidget.html">QWidget</a> * <i>parent</i>, const <a href="qstring.html">QString</a> &amp; <i>title</i>, const <a href="qstring.html">QString</a> &amp; <i>label</i>, <a href="qlineedit.html#EchoMode-enum">QLineEdit::EchoMode</a> <i>mode</i> = QLineEdit::Normal, const <a href="qstring.html">QString</a> &amp; <i>text</i> = QString(), bool * <i>ok</i> = 0, <a href="qt.html#WFlags-typedef">Qt::WFlags</a> <i>f</i> = 0 )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
111
<p>Static convenience function to get a string from the user. <i>title</i> is the text which is displayed in the title bar of the dialog. <i>label</i> is the text which is shown to the user (it should say what should be entered). <i>text</i> is the default text which is placed in the line edit. The <i>mode</i> is the echo mode the line edit will use. If <i>ok</i> is non-null <i>*a</i> ok will be set to true if the user pressed <b>OK</b> and to false if the user pressed <b>Cancel</b>. The dialog's parent is <i>parent</i>. The dialog will be modal and uses the widget flags <i>f</i>.</p>
 
112
<p>This function returns the text which has been entered in the line edit. It will not return an empty string.</p>
 
113
<p>Use this static function like this:</p>
 
114
<pre>&nbsp;       bool ok;
 
115
        QString text = QInputDialog::getText(this, tr(&quot;QInputDialog::getText()&quot;),
 
116
                                             tr(&quot;User name:&quot;), QLineEdit::Normal,
 
117
                                             QDir::home().dirName(), &amp;ok);
 
118
        if (ok &amp;&amp; !text.isEmpty())
 
119
            textLabel-&gt;setText(text);</pre>
 
120
<p>See also <a href="qinputdialog.html#getInteger">getInteger</a>(), <a href="qinputdialog.html#getDouble">getDouble</a>(), and <a href="qinputdialog.html#getItem">getItem</a>().</p>
 
121
<p /><address><hr /><div align="center">
 
122
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
123
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
124
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
125
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
126
</tr></table></div></address></body>
 
127
</html>