QInputDialog Class Reference
|
|
|
The QInputDialog class provides a simple convenience dialog to get a single value from the user.
The input value can be a string, a number or an item from a list. A label must be set to tell the user what they should enter.
Four static convenience functions are provided: getText(), getInt(), getDouble(), and getItem(). All the functions can be used in a similar way, for example:
bool ok; QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"), tr("User name:"), QLineEdit::Normal, QDir::home().dirName(), &ok); if (ok && !text.isEmpty()) textLabel->setText(text);
The ok variable is set to true if the user clicks OK; otherwise it is set to false.
The Standard Dialogs example shows how to use QInputDialog as well as other built-in Qt dialogs.
See also QMessageBox and Standard Dialogs Example.
This enum specifies various options that affect the look and feel of an input dialog.
Константа | Значение | Описание |
---|---|---|
QInputDialog::NoButtons | 0x00000001 | Не показывать кнопки OK и Cancel buttons. (Полезно для "живых диалогов".) |
QInputDialog::UseListViewForComboBoxItems | 0x00000002 | Use a QListView rather than a non-editable QComboBox for displaying the items set with setComboBoxItems(). |
Данное перечисление было введено в Qt 4.5.
The InputDialogOptions type is a typedef for QFlags<InputDialogOption>. It stores an OR combination of InputDialogOption values.
Смотрите также options, setOption() и testOption().
This enum describes the different modes of input that can be selected for the dialog.
Константа | Значение | Описание |
---|---|---|
QInputDialog::TextInput | 0 | Used to input text strings. |
QInputDialog::IntInput | 1 | Used to input integers. |
QInputDialog::DoubleInput | 2 | Used to input floating point numbers with double precision accuracy. |
Данное перечисление было введено в Qt 4.5.
See also inputMode.
This property holds the text for the button used to cancel the dialog.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds whether or not the combo box is used in the input dialog is editable.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the items used in the combobox for the input dialog.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds sets the percision of the double spinbox in decimals.
Это свойство было введено в Qt 4.5.
Функции доступа:
See also QDoubleSpinBox::setDecimals().
This property holds the maximum double precision floating point value accepted as input.
This property is only relevant when the input dialog is used in DoubleInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the minimum double precision floating point value accepted as input.
This property is only relevant when the input dialog is used in DoubleInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the current double precision floating point value accepted as input.
This property is only relevant when the input dialog is used in DoubleInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the mode used for input.
This property help determines which widget is used for entering input into the dialog.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the maximum integer value accepted as input.
This property is only relevant when the input dialog is used in IntInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the minimum integer value accepted as input.
This property is only relevant when the input dialog is used in IntInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the step by which the integer value is increased and decreased.
This property is only relevant when the input dialog is used in IntInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the current integer value accepted as input.
This property is only relevant when the input dialog is used in IntInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the text to for the label to describe what needs to be input.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the text for the button used to accept the entry in the dialog.
Это свойство было введено в Qt 4.5.
Функции доступа:
Это свойство содержит различные опции, которые влияют на внешний вид и поведение диалога.
По умолчанию все опции отключены.
Это свойство было введено в Qt 4.5.
Функции доступа:
Смотрите также setOption() и testOption().
This property holds the echo mode for the text value.
This property is only relevant when the input dialog is used in TextInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
This property holds the text value for the input dialog.
This property is only relevant when the input dialog is used in TextInput mode.
Это свойство было введено в Qt 4.5.
Функции доступа:
Constructs a new input dialog with the given parent and window flags.
Эта функция была введена в Qt 4.5.
Destroys the input dialog.
Эта функция была введена в Qt 4.5.
Закрывает диалог и устанавливает его код результата в result. Если этот диалог показывается с помощью exec(), done() вызывает завершение локального цикла обработки событий, а exec(), чтобы вернуть result.
Повторно реализовано из QDialog.
Смотрите также QDialog::done().
This signal is emitted whenever the double value changes in the dialog. The current value is specified by value.
This signal is only relevant when the input dialog is used in DoubleInput mode.
This signal is emitted whenever the user selects a double value by accepting the dialog; for example, by clicking the OK button. The selected value is specified by value.
This signal is only relevant when the input dialog is used in DoubleInput mode.
Static convenience function to get a floating point number from the user.
title 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 say what should be entered). value is the default floating point number that the line edit will be set to. min and max are the minimum and maximum values the user may choose. decimals is the maximum number of decimal places the number may have.
If ok is nonnull, *ok will be set to true if the user pressed OK and to false if the user pressed Cancel. The dialog's parent is parent. The dialog will be modal and uses the widget flags.
This function returns the floating point number which has been entered by the user.
Use this static function like this:
bool ok; double d = QInputDialog::getDouble(this, tr("QInputDialog::getDouble()"), tr("Amount:"), 37.56, -10000, 10000, 2, &ok); if (ok) doubleLabel->setText(QString("$%1").arg(d));
Предупреждение: Не удаляйте parent во время выполнения диалога. If you want to do this, you should create the dialog yourself using one of the QInputDialog constructors.
See also getText(), getInt(), and getItem().
Static convenience function to get an integer input from the user.
title 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 say what should be entered). value is the default integer which the spinbox will be set to. min and max are the minimum and maximum values the user may choose. step is the amount by which the values change as the user presses the arrow buttons to increment or decrement the value.
If ok is nonnull *ok will be set to true if the user pressed OK and to false if the user pressed Cancel. The dialog's parent is parent. The dialog will be modal and uses the widget flags.
On success, this function returns the integer which has been entered by the user; on failure, it returns the initial value.
Use this static function like this:
bool ok; int i = QInputDialog::getInt(this, tr("QInputDialog::getInteger()"), tr("Percentage:"), 25, 0, 100, 1, &ok); if (ok) integerLabel->setText(tr("%1%").arg(i));
Предупреждение: Не удаляйте parent во время выполнения диалога. If you want to do this, you should create the dialog yourself using one of the QInputDialog constructors.
Эта функция была введена в Qt 4.5.
See also getText(), getDouble(), and getItem().
Static convenience function to let the user select an item from a string list.
title 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 say what should be entered). items is the string list which is inserted into the combobox. current is the number of the item which should be the current item.
If editable is true the user can enter their own text; otherwise the user may only select one of the existing items.
If ok is nonnull *a ok will be set to true if the user pressed OK and to false if the user pressed Cancel. The dialog's parent is parent. The dialog will be modal and uses the widget flags.
This function returns the text of the current item, or if editable is true, the current text of the combobox.
Use this static function like this:
QStringList items; items << tr("Spring") << tr("Summer") << tr("Fall") << tr("Winter"); bool ok; QString item = QInputDialog::getItem(this, tr("QInputDialog::getItem()"), tr("Season:"), items, 0, false, &ok); if (ok && !item.isEmpty()) itemLabel->setText(item);
Предупреждение: Не удаляйте parent во время выполнения диалога. If you want to do this, you should create the dialog yourself using one of the QInputDialog constructors.
See also getText(), getInt(), and getDouble().
Static convenience function to get a string from the user.
title 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 say what should be entered). text is the default text which is placed in the line edit. mode is the echo mode the line edit will use.
If ok is nonnull *a ok will be set to true if the user pressed OK and to false if the user pressed Cancel. The dialog's parent is parent. The dialog will be modal and uses the specified widget flags.
If the dialog is accepted, this function returns the text in the dialog's line edit. If the dialog is rejected, a null QString is returned.
Use this static function like this:
bool ok; QString text = QInputDialog::getText(this, tr("QInputDialog::getText()"), tr("User name:"), QLineEdit::Normal, QDir::home().dirName(), &ok); if (ok && !text.isEmpty()) textLabel->setText(text);
Предупреждение: Не удаляйте parent во время выполнения диалога. If you want to do this, you should create the dialog yourself using one of the QInputDialog constructors.
See also getInt(), getDouble(), and getItem().
This signal is emitted whenever the integer value changes in the dialog. The current value is specified by value.
This signal is only relevant when the input dialog is used in IntInput mode.
This signal is emitted whenever the user selects a integer value by accepting the dialog; for example, by clicking the OK button. The selected value is specified by value.
This signal is only relevant when the input dialog is used in IntInput mode.
Это перегруженная функция.
This function connects one of its signals to the slot specified by receiver and member. The specific signal depends on the arguments that are specified in member. Ими являются:
Сигнал будет отсоединен от слота когда диалог закрывается.
Эта функция была введена в Qt 4.5.
Sets the range of double precision floating point values accepted by the dialog when used in DoubleInput mode, with minimum and maximum values specified by min and max respectively.
Sets the range of integer values accepted by the dialog when used in IntInput mode, with minimum and maximum values specified by min and max respectively.
Устанавливает заданную опцию option включённой если on равно true; в противном случае очищает заданную опцию option.
Смотрите также options и testOption().
Возвращает true если заданная опция option включена; в противном случае возвращается false.
Смотрите также options и setOption().
This signal is emitted whenever the text string changes in the dialog. The current string is specified by text.
This signal is only relevant when the input dialog is used in TextInput mode.
This signal is emitted whenever the user selects a text string by accepting the dialog; for example, by clicking the OK button. The selected string is specified by text.
This signal is only relevant when the input dialog is used in TextInput mode.
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Торговые марки | Qt 4.5.3 |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |