|  | Home · Overviews · Examples

# QInputDialog Class Reference
[com.trolltech.qt.gui module]

The QInputDialog class provides a simple convenience dialog to get a single value from the user. More...

Inherits `QDialog`.

## Detailed Description

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.