| Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QInputDialog class provides a simple convenience dialog to get a single value from the user. More...
#include <qinputdialog.h>
Inherits QDialog.
The QInputDialog is a simple dialog which can be used if you need to get a single input value from the user. The input value can be a string, a number or an item from a list. A label has to be set to tell the user what they should input.
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 = FALSE;
QString text = QInputDialog::getText(
tr( "Application name" ),
tr( "Please enter your name" ),
QLineEdit::Normal, QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed OK
else
;// user entered nothing or pressed Cancel

See also Dialog Classes.
If ok is not-null it will be set to TRUE if the user pressed OK and FALSE if the user pressed Cancel. The dialog's parent is parent; the dialog is called name. The dialog will be modal.
This method returns the floating point number which has been entered by the user.
Use this static method like this:
bool ok = FALSE;
double res = QInputDialog::getDouble(
tr( "Application name" ),
tr( "Please enter a decimal number" ),
33.7, 0, 1000, 2, &ok, this );
if ( ok )
;// user entered something and pressed OK
else
;// user pressed Cancel
If ok is not-null it will be set to TRUE if the user pressed OK and FALSE if the user pressed Cancel. The dialog's parent is parent; the dialog is called name. The dialog will be modal.
This method returns the number which has been entered by the user.
Use this static method like this:
bool ok = FALSE;
int res = QInputDialog::getInteger(
tr( "Application name" ),
tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
if ( ok )
;// user entered something and pressed OK
else
;// user pressed Cancel
If ok is not-null it will be set to TRUE if the user pressed OK and FALSE if the user pressed Cancel. The dialog's parent is parent; the dialog is called name. The dialog will be modal.
This method returns the text of the current item, or if editable is TRUE, the current text of the combobox.
Use this static method like this:
QStringList lst;
lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
bool ok = FALSE;
QString res = QInputDialog::getItem(
tr( "Application name" ),
tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
if ( ok )
;// user selected an item and pressed OK
else
;// user pressed Cancel
This method returns the text which has been entered in the line edit.
Use this static method like this:
bool ok = FALSE;
QString text = QInputDialog::getText(
tr( "Application name" ),
tr( "Please enter your name" ),
QLineEdit::Normal, QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed OK
else
;// user entered nothing or pressed Cancel
Example: network/ftpclient/ftpmainwindow.cpp.
This file is part of the Qt toolkit. Copyright © 1995-2002 Trolltech. All Rights Reserved.
| Copyright © 2002 Trolltech | Trademarks | Qt version 3.0.3
|