| Home · Overviews · Examples |
The QInputDialog class provides a simple convenience dialog to get a single value from the user. More...
Inherits QDialog.
The QInputDialog class provides a simple convenience dialog to get a single value from the user.
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.
Four static convenience functions are provided: getText(), getInteger(), getDouble() and getItem(). All the functions can be used in a similar way, for example:
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);
The ok variable is set to true if the user clicks OK; otherwise it is set to false.

The Standard Dialogs example shows how to use QInputDialog as well as other built-in Qt dialogs.
See also QMessageBox and Standard Dialogs Example.
| Copyright © 2007 Trolltech | Trademarks | Qt Jambi 4.3.2_01 |