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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
'\" t
.TH QInputDialog 3qt "18 March 2002" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QInputDialog \- Simple convenience dialog to get a single value from the user
.SH SYNOPSIS
\fC#include <qinputdialog.h>\fR
.PP
Inherits QDialog.
.PP
.SS "Static Public Members"
.TP
QString \fBgetText\fR ( const QString & caption, const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 )
.TP
int \fBgetInteger\fR ( 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 )
.TP
double \fBgetDouble\fR ( 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 )
.TP
QString \fBgetItem\fR ( 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 )
.SH DESCRIPTION
The QInputDialog class provides a simple convenience dialog to get a single value from the user.
.PP
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.
.PP
Four static convenience functions are provided: getText(), getInteger(), getDouble() and getItem(). All the functions can be used in a similar way, for example:
.PP
.nf
.br
bool ok = FALSE;
.br
QString text = QInputDialog::getText(
.br
tr( "Application name" ),
.br
tr( "Please enter your name" ),
.br
QLineEdit::Normal, QString::null, &ok, this );
.br
if ( ok && !text.isEmpty() )
.br
;// user entered something and pressed OK
.br
else
.br
;// user entered nothing or pressed Cancel
.br
.fi
.PP
<center>
.ce 1
.B "[Image Omitted]"
.PP
</center>
.PP
See also Dialog Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "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 )\fC [static]\fR"
Static convenience function to get a floating point number from the user. \fIcaption\fR is the text which is displayed in the title bar of the dialog. \fIlabel\fR is the text which is shown to the user (it should mention what they should input), \fInum\fR is the default floating point number that the line edit will be set to. \fIfrom\fR and \fIto\fR are the minimum and maximum values the user may choose, and \fIdecimals\fR is the maximum number of decimal places the number may have.
.PP
If \fIok\fR 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 \fIparent\fR; the dialog is called \fIname\fR. The dialog will be modal.
.PP
This method returns the floating point number which has been entered by the user.
.PP
Use this static method like this:
.PP
.nf
.br
bool ok = FALSE;
.br
double res = QInputDialog::getDouble(
.br
tr( "Application name" ),
.br
tr( "Please enter a decimal number" ),
.br
33.7, 0, 1000, 2, &ok, this );
.br
if ( ok )
.br
;// user entered something and pressed OK
.br
else
.br
;// user pressed Cancel
.br
.fi
.SH "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 )\fC [static]\fR"
Static convenience function to get an integer input from the user. \fIcaption\fR is the text which is displayed in the title bar of the dialog. \fIlabel\fR is the text which is shown to the user (it should mention what they should input), \fInum\fR is the default number which the spinbox will be set to. \fIfrom\fR and \fIto\fR are the minimum and maximum values the user may choose, and \fIstep\fR is the amount by which the values change as the user presses the arrow buttons to increment or decrement the value.
.PP
If \fIok\fR 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 \fIparent\fR; the dialog is called \fIname\fR. The dialog will be modal.
.PP
This method returns the number which has been entered by the user.
.PP
Use this static method like this:
.PP
.nf
.br
bool ok = FALSE;
.br
int res = QInputDialog::getInteger(
.br
tr( "Application name" ),
.br
tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
.br
if ( ok )
.br
;// user entered something and pressed OK
.br
else
.br
;// user pressed Cancel
.br
.fi
.SH "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 )\fC [static]\fR"
Static convenience function to let the user select an item from a string list. \fIcaption\fR is the text which is displayed in the title bar of the dialog. \fIlabel\fR is the text which is shown to the user (it should mention what they should input). \fIlist\fR is the string list which is inserted into the combobox, and \fIcurrent\fR is the number of the item which should be the current item. If \fIeditable\fR is TRUE the user can enter their own text; if \fIeditable\fR is FALSE the user may only select one of the existing items.
.PP
If \fIok\fR 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 \fIparent\fR; the dialog is called \fIname\fR. The dialog will be modal.
.PP
This method returns the text of the current item, or if \fIeditable\fR is TRUE, the current text of the combobox.
.PP
Use this static method like this:
.PP
.nf
.br
QStringList lst;
.br
lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
.br
bool ok = FALSE;
.br
QString res = QInputDialog::getItem(
.br
tr( "Application name" ),
.br
tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
.br
if ( ok )
.br
;// user selected an item and pressed OK
.br
else
.br
;// user pressed Cancel
.br
.fi
.SH "QString QInputDialog::getText ( const QString & caption, const QString & label, QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 )\fC [static]\fR"
Static convenience function to get a string from the user. \fIcaption\fR is the text which is displayed in the title bar of the dialog. \fIlabel\fR is the text which is shown to the user (it should mention what they should input), \fItext\fR the default text which is placed in the line edit. The \fImode\fR is the echo mode the line edit will use. If \fIok\fR 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 \fIparent\fR; the dialog is called \fIname\fR. The dialog will be modal.
.PP
This method returns the text which has been entered in the line edit.
.PP
Use this static method like this:
.PP
.nf
.br
bool ok = FALSE;
.br
QString text = QInputDialog::getText(
.br
tr( "Application name" ),
.br
tr( "Please enter your name" ),
.br
QLineEdit::Normal, QString::null, &ok, this );
.br
if ( ok && !text.isEmpty() )
.br
;// user entered something and pressed OK
.br
else
.br
;// user entered nothing or pressed Cancel
.br
.fi
.PP
Example: network/ftpclient/ftpmainwindow.cpp.
.SH "SEE ALSO"
.BR http://doc.trolltech.com/qinputdialog.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qinputdialog.3qt) and the Qt
version (3.0.3).
|