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">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <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 <i>ok</i>) <b><a href="qinputdialog.html#getDouble">getDouble</a></b> (QWidget <i>parent</i>, QString <i>title</i>, QString <i>label</i>, float <i>value</i> = 0, float <i>minValue</i> = -2147483647, float <i>maxValue</i> = 2147483647, int <i>decimals</i> = 1, Qt.WindowFlags <i>f</i> = 0)</li><li><div class="fn" />(int, bool <i>ok</i>) <b><a href="qinputdialog.html#getInteger">getInteger</a></b> (QWidget <i>parent</i>, QString <i>title</i>, QString <i>label</i>, int <i>value</i> = 0, int <i>minValue</i> = -2147483647, int <i>maxValue</i> = 2147483647, int <i>step</i> = 1, Qt.WindowFlags <i>f</i> = 0)</li><li><div class="fn" />(QString, bool <i>ok</i>) <b><a href="qinputdialog.html#getItem">getItem</a></b> (QWidget <i>parent</i>, QString <i>title</i>, QString <i>label</i>, QStringList <i>list</i>, int <i>current</i> = 0, bool <i>editable</i> = True, Qt.WindowFlags <i>f</i> = 0)</li><li><div class="fn" />(QString, bool <i>ok</i>) <b><a href="qinputdialog.html#getText">getText</a></b> (QWidget <i>parent</i>, QString <i>title</i>, QString <i>label</i>, QLineEdit.EchoMode <i>echo</i> = QLineEdit.Normal, QString <i>text</i> = QString(), Qt.WindowFlags <i>f</i> = 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(), &ok);
if (ok && !text.isEmpty())
textLabel->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 <i>ok</i>) QInputDialog.getDouble (<a href="qwidget.html">QWidget</a> <i>parent</i>, <a href="qstring.html">QString</a> <i>title</i>, <a href="qstring.html">QString</a> <i>label</i>, float <i>value</i> = 0, float <i>minValue</i> = -2147483647, float <i>maxValue</i> = 2147483647, int <i>decimals</i> = 1, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 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, &ok);
if (ok)
doubleLabel->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 <i>ok</i>) QInputDialog.getInteger (<a href="qwidget.html">QWidget</a> <i>parent</i>, <a href="qstring.html">QString</a> <i>title</i>, <a href="qstring.html">QString</a> <i>label</i>, int <i>value</i> = 0, int <i>minValue</i> = -2147483647, int <i>maxValue</i> = 2147483647, int <i>step</i> = 1, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 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, &ok);
if (ok)
integerLabel->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 <i>ok</i>) QInputDialog.getItem (<a href="qwidget.html">QWidget</a> <i>parent</i>, <a href="qstring.html">QString</a> <i>title</i>, <a href="qstring.html">QString</a> <i>label</i>, <a href="qstringlist.html">QStringList</a> <i>list</i>, int <i>current</i> = 0, bool <i>editable</i> = True, <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 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 << tr("Spring") << tr("Summer") << tr("Fall") << tr("Winter");
bool ok;
QString item = QInputDialog.getItem(this, tr("QInputDialog.getItem()"),
tr("Season:"), items, 0, false, &ok);
if (ok && !item.isEmpty())
itemLabel->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 <i>ok</i>) QInputDialog.getText (<a href="qwidget.html">QWidget</a> <i>parent</i>, <a href="qstring.html">QString</a> <i>title</i>, <a href="qstring.html">QString</a> <i>label</i>, <a href="qlineedit.html#EchoMode-enum">QLineEdit.EchoMode</a> <i>echo</i> = QLineEdit.Normal, <a href="qstring.html">QString</a> <i>text</i> = QString(), <a href="qt-windowflags.html">Qt.WindowFlags</a> <i>f</i> = 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(), &ok);
if (ok && !text.isEmpty())
textLabel->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 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|