QInputDialog - A convenience dialog to get a simple input
from the user
#include <qinputdialog.h>
Inherits QDialog.
Static Public Members
QString getText ( const QString & caption, const QString &
label, const QString & text = QString::null, bool *
ok = 0, QWidget * parent = 0, const char * name = 0
)
QString getText ( const QString & caption, const QString &
label, QLineEdit::EchoMode echo, const QString &
text = QString::null, bool * ok = 0, QWidget *
parent = 0, const char * name = 0 )
int getInteger ( const QString & caption, const QString &
label, int num = 0, int from = -2147483647, int to
= 2147483647, int step = 1, bool * ok = 0, QWidget
* parent = 0, const char * name = 0 )
double getDouble ( const QString & caption, const QString
& label, double num = 0, double from = -2147483647,
double to = 2147483647, int decimals = 1, bool * ok
= 0, QWidget * parent = 0, const char * name = 0 )
QString getItem ( const QString & caption, const QString &
label, const QStringList & list, int current = 0,
bool editable = TRUE, bool * ok = 0, QWidget *
parent = 0, const char * name = 0 )
DESCRIPTION
A convenience dialog to get a simple input from the user
The QInputDialog is a simple dialog which can be used if
you need a simple input from the user. This can be text, a
number or an item from a list. Also a label has to be set
to tell the user what he/she should input.
In this Qt version only the 4 static convenience functions
getText(), getInteger(), getDouble() and getItem() of
QInputDialog are available.
Use it like this:
bool ok = FALSE;
QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed ok
else
There are more static convenience methods!
See also getText(), getInteger(), getDouble() and
getItem().
MEMBER FUNCTION DOCUMENTATION
double QInputDialog::getDouble ( const QString & caption, const
QString & label, double num = 0, double from =
-2147483647, double to = 2147483647, int decimals = 1,
bool * ok = 0, QWidget * parent = 0, const char * name = 0
) [static]
Static convenience function to get a decimal input from
the user. caption is the text which is displayed in the
title bar of the dialog. label is the text which is shown
to the user (it should mention to the user what he/she
should input), num the default decimal number which will
be initially set to the line edit, from and to the range
in which the entered number has to be, decimals the number
of decimal which the number may have, ok a pointer to a
bool which will be (if not 0!) set to TRUE if the user
pressed ok or to FALSE if the user pressed cancel, parent
the parent widget of the dialog and name the name of it.
The dialogs pops up modally!
This method returns the number which has been entered by
the user.
You will use this static method like this:
bool ok = FALSE;
double res = QInputDialog::getDouble( 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
int QInputDialog::getInteger ( const QString & caption, const
QString & label, int num = 0, int from = -2147483647, int
to = 2147483647, int step = 1, bool * ok = 0, QWidget *
parent = 0, const char * name = 0 ) [static]
Static convenience function to get an integral input from
the user. caption is the text which is displayed in the
title bar of the dialog. label is the text which is shown
to the user (it should mention to the user what he/she
should input), num the default number which will be
initially set to the spinbox, from and to the range in
which the entered number has to be, step the step in which
the number can be increased/decreased by the spinbox, ok a
pointer to a bool which will be (if not 0!) set to TRUE if
the user pressed ok or to FALSE if the user pressed
cancel, parent the parent widget of the dialog and name
the name of it. The dialogs pops up modally!
the user.
You will use this static method like this:
bool ok = FALSE;
int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
if ( ok )
;// user entered something and pressed ok
else
;// user pressed cancel
QString QInputDialog::getItem ( const QString & caption, const
QString & label, const QStringList & list, int current =
0, bool editable = TRUE, bool * ok = 0, QWidget * parent =
0, const char * name = 0 ) [static]
Static convenience function to let the user select an item
from a string list. caption is the text which is displayed
in the title bar of the dialog. label is the text which is
shown to the user (it should mention to the user what
he/she should input), list the string list which is
inserted into the combobox, current the number of the item
which should be initially the current item, editable
specifies if the combobox should be editable (if it is
TRUE) or read-only (if editable is FALSE), ok a pointer to
a bool which will be (if not 0!) set to TRUE if the user
pressed ok or to FALSE if the user pressed cancel, parent
the parent widget of the dialog and name the name of it.
The dialogs pops up modally!
This method returns the text of the current item, or if
editable was TRUE, the current text of the combobox.
You will use this static method like this:
QStringList lst;
lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
bool ok = FALSE;
QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
if ( ok )
;// user selected an item and pressed ok
else
;// user pressed cancel
QString QInputDialog::getText ( const QString & caption, const
QString & label, QLineEdit::EchoMode mode, const QString &
text = QString::null, bool * ok = 0, QWidget * parent = 0,
const char * name = 0 ) [static]
Like above, but accepts an a mode which the line edit will
use to display text.
See also getText().
QString & label, const QString & text = QString::null,
bool * ok = 0, QWidget * parent = 0, const char * name = 0
) [static]
Static convenience function to get a textual input from
the user. caption is the text which is displayed in the
title bar of the dialog. label is the text which is shown
to the user (it should mention to the user what he/she
should input), text the default text which will be
initially set to the line edit, ok a pointer to a bool
which will be (if not 0!) set to TRUE if the user pressed
ok or to FALSE if the user pressed cancel, parent the
parent widget of the dialog and name the name of it. The
dialogs pops up modally!
This method returns the text which has been entered in the
line edit.
You will use this static method like this:
bool ok = FALSE;
QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this );
if ( ok && !text.isEmpty() )
;// user entered something and pressed ok
else
;// user entered nothing or pressed cancel
SEE ALSO
http://doc.trolltech.com/qinputdialog.html
http://www.trolltech.com/faq/tech.html
COPYRIGHT
Copyright 1992-2001 Trolltech AS,
http://www.trolltech.com. See the license file included
in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in
http://doc.trolltech.com/bughowto.html. Good bug reports
make our job much simpler. Thank you.
In case of content or formattting problems with this
manual page, please report them to qt-bugs@trolltech.com.
Please include the name of the manual page
(qinputdialog.3qt) and the Qt version (2.3.1).
Man(1) output converted with
man2html