A convenience dialog to get a simple input from the user More...
#include <qlinedialog.h>
Inherits QDialog.
The QLineDialog 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.
To be able to get different types of inputs, you can set the input type of the dialog with setType().
To e.g. get a textual input from the user you can use one of the static methods like this:
bool ok = FALSE; QString text = QLineDialog::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
There are more static convenience methods!
See also: getText(), getInteger(), getDouble() and getItem().
LineEdit
- A QLineEdit is used for taking the input, so a textual or
(e.g. using a QValidator) a numerical input can be done. Using lineEdit()
the QLineEdit can be accessed.
SpinBox
- A QSpinBox is used for taking the input, so a decimal
input can be done. Using spinBox() the QSpinBox can be accessed.
ComboBox
- A readonly QComboBox is used for taking the input,
so one item of a list can be chosen. Using comboBox() the QComboBox
can be accessed.
EditableComboBox
- An editable QComboBox is used for taking the input,
so either one item of a list can be chosen or a text can be entered. Using
editableComboBox() the QComboBox can be accessed.
Constructs the dialog. label is the text which is shown to the user (it should mention to the user what he/she should input), parent the parent widget of the dialog, name the name of it and if you set modal to TRUE, the dialog pops up modally, else it pops up modeless. With type you specify the type of the dialog.
See also: getText(), getInteger(), getDouble() and getItem().
Destructor.
Returns the combobox, which is used in the ComboBox mode.
Returns the combobox, which is used in the EditableComboBox mode.
[static]
Static convenience function to get a decimal input from the user. 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 = QLineDialog::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
[static]
Static convenience function to get an integral input from the user. 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!
This method returns the number which has been entered by the user.
You will use this static method like this:
bool ok = FALSE; int res = QLineDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this ); if ( ok ) ;// user entered something and pressed ok else ;// user pressed cancel
[static]
Static convenience function to let the user select an item from a string list. 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 nimber of the item which should be initially the current item, editable specifies if the combobox should be editable (if it is TRUE) or readonly (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 = QLineDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this ); if ( ok ) ;// user selected an item and pressed ok else ;// user pressed cancel
[static]
Static convenience function to get a textual input from the user. 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 = QLineDialog::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
Returns the line edit, which is used in the LineEdit mode.
Sets the input type of the dialog to t.
Returns the spinbox, which is used in the SpinBox mode.
Returns the input type of the dialog.
See also: setType().
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-2000 Troll Tech, all rights reserved.
Copyright İ 2000 Troll Tech | Trademarks | Qt version 2.1.0 (pre-release)
|