📄 qinputdialog.3qt
字号:
'\" t.TH QInputDialog 3qt "5 August 2004" "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 NAMEQInputDialog \- A convenience dialog to get a simple input from the user.br.PP\fC#include <qinputdialog.h>\fR.PPInherits QDialog..PP.SS "Static Public Members".TPQString \fBgetText\fR ( const QString & caption, const QString & label, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 ) .TPQString \fBgetText\fR ( const QString & caption, const QString & label, QLineEdit::EchoMode echo, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 ) .TPint \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 ) .TPdouble \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 ) .TPQString \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 DESCRIPTIONA convenience dialog to get a simple input from the user.PPThe 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..PPIn this Qt version only the 4 static convenience functions getText(), getInteger(), getDouble() and getItem() of QInputDialog are available..PPUse it like this:.PP.nf.br bool ok = FALSE;.br QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), 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.fi.PPThere are more static convenience methods!.PPSee also getText(), getInteger(), getDouble() and getItem()..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 decimal 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 to the user what he/she should input), \fInum\fR the default decimal number which will be initially set to the line edit, \fIfrom\fR and \fIto\fR the range in which the entered number has to be, \fIdecimals\fR the number of decimal which the number may have, \fIok\fR 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, \fIparent\fR the parent widget of the dialog and \fIname\fR the name of it. The dialogs pops up modally!.PPThis method returns the number which has been entered by the user..PPYou will use this static method like this:.PP.nf.br bool ok = FALSE;.br double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this );.br if ( ok ).br ;// user entered something and pressed ok.br else.br ;// user pressed cancel.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 integral 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 to the user what he/she should input), \fInum\fR the default number which will be initially set to the spinbox, \fIfrom\fR and \fIto\fR the range in which the entered number has to be, \fIstep\fR the step in which the number can be increased/decreased by the spinbox, \fIok\fR 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, \fIparent\fR the parent widget of the dialog and \fIname\fR the name of it. The dialogs pops up modally!.PPThis method returns the number which has been entered by the user..PPYou will use this static method like this:.PP.nf.br bool ok = FALSE;.br int res = QInputDialog::getInteger( 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.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 to the user what he/she should input), \fIlist\fR the string list which is inserted into the combobox, \fIcurrent\fR the number of the item which should be initially the current item, \fIeditable\fR specifies if the combobox should be editable (if it is TRUE) or read-only (if \fIeditable\fR is FALSE), \fIok\fR 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, \fIparent\fR the parent widget of the dialog and \fIname\fR the name of it. The dialogs pops up modally!.PPThis method returns the text of the current item, or if \fIeditable\fR was TRUE, the current text of the combobox..PPYou will 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( 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.fi.SH "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 ) \fC[static]\fR"Like above, but accepts an a \fImode\fR which the line edit will use to display text..PPSee also getText()..SH "QString QInputDialog::getText ( const QString & caption, const QString & label, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 ) \fC[static]\fR"Static convenience function to get a textual 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 to the user what he/she should input), \fItext\fR the default text which will be initially set to the line edit, \fIok\fR 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, \fIparent\fR the parent widget of the dialog and \fIname\fR the name of it. The dialogs pops up modally!.PPThis method returns the text which has been entered in the line edit..PPYou will use this static method like this:.PP.nf.br bool ok = FALSE;.br QString text = QInputDialog::getText( tr( "Please enter your name" ), 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.fi.SH "SEE ALSO".BR http://doc.trolltech.com/qinputdialog.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qinputdialog.3qt) and the Qtversion (2.3.8).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -