File: qinputdialog.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (76 lines) | stat: -rw-r--r-- 12,277 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QInputDialog Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QInputDialog Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QInputDialog class provides a simple convenience dialog to get a single value from the user. <a href="#details">More...</a></p>
<p>Inherits <a href="qdialog.html">QDialog</a>.</p><h3>Static Methods</h3><ul><li><div class="fn" />(float, bool&#160;<i>ok</i>) <b><a href="qinputdialog.html#getDouble">getDouble</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>title</i>, QString&#160;<i>label</i>, float&#160;<i>value</i>&#160;=&#160;0, float&#160;<i>minValue</i>&#160;=&#160;-2147483647, float&#160;<i>maxValue</i>&#160;=&#160;2147483647, int&#160;<i>decimals</i>&#160;=&#160;1, Qt.WindowFlags&#160;<i>f</i>&#160;=&#160;0)</li><li><div class="fn" />(int, bool&#160;<i>ok</i>) <b><a href="qinputdialog.html#getInteger">getInteger</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>title</i>, QString&#160;<i>label</i>, int&#160;<i>value</i>&#160;=&#160;0, int&#160;<i>minValue</i>&#160;=&#160;-2147483647, int&#160;<i>maxValue</i>&#160;=&#160;2147483647, int&#160;<i>step</i>&#160;=&#160;1, Qt.WindowFlags&#160;<i>f</i>&#160;=&#160;0)</li><li><div class="fn" />(QString, bool&#160;<i>ok</i>) <b><a href="qinputdialog.html#getItem">getItem</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>title</i>, QString&#160;<i>label</i>, QStringList&#160;<i>list</i>, int&#160;<i>current</i>&#160;=&#160;0, bool&#160;<i>editable</i>&#160;=&#160;True, Qt.WindowFlags&#160;<i>f</i>&#160;=&#160;0)</li><li><div class="fn" />(QString, bool&#160;<i>ok</i>) <b><a href="qinputdialog.html#getText">getText</a></b> (QWidget&#160;<i>parent</i>, QString&#160;<i>title</i>, QString&#160;<i>label</i>, QLineEdit.EchoMode&#160;<i>echo</i>&#160;=&#160;QLineEdit.Normal, QString&#160;<i>text</i>&#160;=&#160;QString(), Qt.WindowFlags&#160;<i>f</i>&#160;=&#160;0)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QInputDialog class provides a simple convenience dialog to get a single value from the user.</p>
<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>
<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>
<pre>
        bool ok;
        QString text = QInputDialog.getText(this, tr("QInputDialog.getText()"),
                                             tr("User name:"), QLineEdit.Normal,
                                             QDir.home().dirName(), &amp;ok);
        if (ok &amp;&amp; !text.isEmpty())
            textLabel-&gt;setText(text);
</pre>
<p>The <tt>ok</tt> variable is set to true if the user clicks <b>OK</b>; otherwise it is set to false.</p>
<p align="center"><img alt="Input Dialogs" src="images/inputdialogs.png" /></p>
<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>
<p>See also <a href="qmessagebox.html">QMessageBox</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="getDouble" />(float, bool&#160;<i>ok</i>) QInputDialog.getDouble (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>title</i>, <a href="qstring.html">QString</a>&#160;<i>label</i>, float&#160;<i>value</i>&#160;=&#160;0, float&#160;<i>minValue</i>&#160;=&#160;-2147483647, float&#160;<i>maxValue</i>&#160;=&#160;2147483647, int&#160;<i>decimals</i>&#160;=&#160;1, <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>f</i>&#160;=&#160;0)</h3><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>
<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>
<p>This function returns the floating point number which has been entered by the user.</p>
<p>Use this static function like this:</p>
<pre>
        bool ok;
        double d = QInputDialog.getDouble(this, tr("QInputDialog.getDouble()"),
                                           tr("Amount:"), 37.56, -10000, 10000, 2, &amp;ok);
        if (ok)
            doubleLabel-&gt;setText(QString("$%1").arg(d));
</pre>
<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>
<h3 class="fn"><a name="getInteger" />(int, bool&#160;<i>ok</i>) QInputDialog.getInteger (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>title</i>, <a href="qstring.html">QString</a>&#160;<i>label</i>, int&#160;<i>value</i>&#160;=&#160;0, int&#160;<i>minValue</i>&#160;=&#160;-2147483647, int&#160;<i>maxValue</i>&#160;=&#160;2147483647, int&#160;<i>step</i>&#160;=&#160;1, <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>f</i>&#160;=&#160;0)</h3><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>
<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>
<p>This function returns the integer which has been entered by the user.</p>
<p>Use this static function like this:</p>
<pre>
        bool ok;
        int i = QInputDialog.getInteger(this, tr("QInputDialog.getInteger()"),
                                         tr("Percentage:"), 25, 0, 100, 1, &amp;ok);
        if (ok)
            integerLabel-&gt;setText(tr("%1%").arg(i));
</pre>
<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>
<h3 class="fn"><a name="getItem" />(<a href="qstring.html">QString</a>, bool&#160;<i>ok</i>) QInputDialog.getItem (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>title</i>, <a href="qstring.html">QString</a>&#160;<i>label</i>, <a href="qstringlist.html">QStringList</a>&#160;<i>list</i>, int&#160;<i>current</i>&#160;=&#160;0, bool&#160;<i>editable</i>&#160;=&#160;True, <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>f</i>&#160;=&#160;0)</h3><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>
<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>
<p>This function returns the text of the current item, or if <i>editable</i> is true, the current text of the combobox.</p>
<p>Use this static function like this:</p>
<pre>
        QStringList items;
        items &lt;&lt; tr("Spring") &lt;&lt; tr("Summer") &lt;&lt; tr("Fall") &lt;&lt; tr("Winter");

        bool ok;
        QString item = QInputDialog.getItem(this, tr("QInputDialog.getItem()"),
                                             tr("Season:"), items, 0, false, &amp;ok);
        if (ok &amp;&amp; !item.isEmpty())
            itemLabel-&gt;setText(item);
</pre>
<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>
<h3 class="fn"><a name="getText" />(<a href="qstring.html">QString</a>, bool&#160;<i>ok</i>) QInputDialog.getText (<a href="qwidget.html">QWidget</a>&#160;<i>parent</i>, <a href="qstring.html">QString</a>&#160;<i>title</i>, <a href="qstring.html">QString</a>&#160;<i>label</i>, <a href="qlineedit.html#EchoMode-enum">QLineEdit.EchoMode</a>&#160;<i>echo</i>&#160;=&#160;QLineEdit.Normal, <a href="qstring.html">QString</a>&#160;<i>text</i>&#160;=&#160;QString(), <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>f</i>&#160;=&#160;0)</h3><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>
<p>This function returns the text which has been entered in the line edit. It will not return an empty string.</p>
<p>Use this static function like this:</p>
<pre>
        bool ok;
        QString text = QInputDialog.getText(this, tr("QInputDialog.getText()"),
                                             tr("User name:"), QLineEdit.Normal,
                                             QDir.home().dirName(), &amp;ok);
        if (ok &amp;&amp; !text.isEmpty())
            textLabel-&gt;setText(text);
</pre>
<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>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>