⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qinputdialog.cpp

📁 奇趣公司比较新的qt/emd版本
💻 CPP
📖 第 1 页 / 共 2 页
字号:
*//*!  \enum QInputDialog::Type  This enum specifies the type of the dialog, i.e. what kind of data you  want the user to input:  \value LineEdit  A QLineEdit is used for obtaining string or numeric  input. The QLineEdit can be accessed using lineEdit().  \value SpinBox  A QSpinBox is used for obtaining integer input.  Use spinBox() to access the QSpinBox.  \value ComboBox  A read-only QComboBox is used to provide a fixed  list of choices from which the user can choose.  Use comboBox() to access the QComboBox.  \value EditableComboBox  An editable QComboBox is used to provide a fixed  list of choices from which the user can choose, but which also  allows the user to enter their own value instead.  Use editableComboBox() to access the QComboBox.*//*!  Constructs an input dialog of the specified \a type with the given \a parent  widget and window \a flags. The \a text is shown in the dialog with the input  field, and is typically used to tell the user what they are expected to enter.  \sa getText(), getInteger(), getDouble(), getItem()*/// ### Qt 5: removeQInputDialog::QInputDialog(const QString &text, QWidget* parent, Type type, Qt::WindowFlags f)    : QDialog(*new QInputDialogPrivate, parent, f){    Q_D(QInputDialog);    d->init(text, type);}/*!  Constructs the dialog. The \a title is the text which is displayed in  the title bar of the dialog. The \a label is the text which is shown to  the user (it should tell the user what they are expected to enter).  The \a parent is the dialog's parent widget. The \a input parameter  is the dialog to be used. The \a f parameter is passed on to the  QDialog constructor.  \sa getText(), getInteger(), getDouble(), getItem()*/QInputDialog::QInputDialog(    const QString &title, const QString &label, QWidget *parent, QWidget *input,    Qt::WindowFlags f)    : QDialog(*new QInputDialogPrivate, parent, f){    Q_D(QInputDialog);    d->init(title, label, input);}/*!    Destroys the input dialog.*/QInputDialog::~QInputDialog(){}/*!    Static convenience function to get a string from the user. \a    title is the text which is displayed in the title bar of the    dialog. \a label is the text which is shown to the user (it should    say what should be entered). \a text is the default text which is    placed in the line edit. The \a mode is the echo mode the line    edit will use. If \a ok is non-null \e *\a ok will be set to true    if the user pressed \gui OK and to false if the user pressed    \gui Cancel. The dialog's parent is \a parent. The dialog will be    modal and uses the widget flags \a f.    This function returns the text which has been entered in the line    edit. It will not return an empty string.    Use this static function like this:    \quotefromfile dialogs/standarddialogs/dialog.cpp    \skipuntil Dialog::setText    \skipline {    \printto }    \sa getInteger(), getDouble(), getItem()*/QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label,                               QLineEdit::EchoMode mode, const QString &text,                               bool *ok, Qt::WindowFlags f){    QLineEdit *le = new QLineEdit;    le->setText(text);    le->setEchoMode(mode);    le->setFocus();    le->selectAll();    QInputDialog dlg(title, label, parent, le, f);    QString result;    bool accepted = (dlg.exec() == QDialog::Accepted);    if (ok)        *ok = accepted;    if (accepted)        result = le->text();    return result;}/*!    Static convenience function to get an integer input from the    user. \a title is the text which is displayed in the title bar    of the dialog.  \a label is the text which is shown to the user    (it should say what should be entered). \a value is the default    integer which the spinbox will be set to.  \a minValue and \a    maxValue are the minimum and maximum values the user may choose,    and \a step is the amount by which the values change as the user    presses the arrow buttons to increment or decrement the value.    If \a ok is non-null *\a ok will be set to true if the user    pressed \gui OK and to false if the user pressed \gui Cancel. The    dialog's parent is \a parent. The dialog will be modal and uses    the widget flags \a f.    This function returns the integer which has been entered by the user.    Use this static function like this:    \quotefromfile dialogs/standarddialogs/dialog.cpp    \skipuntil Dialog::setInteger    \skipline {    \printto }    \sa getText(), getDouble(), getItem()*/int QInputDialog::getInteger(QWidget *parent, const QString &title, const QString &label,                             int value, int minValue, int maxValue, int step, bool *ok,                             Qt::WindowFlags f){    QInputDialogValidatedSpinBox *sb =        new QInputDialogValidatedSpinBox(minValue, maxValue, step, value);    QInputDialog dlg(title, label, parent, sb, f);    QObject::connect(        sb, SIGNAL(textChanged(bool)), qobject_cast<QPushButton*>(dlg.d_func()->okButton),        SLOT(setEnabled(bool)));    bool accepted = (dlg.exec() == QDialog::Accepted);    if (ok)        *ok = accepted;    return sb->value();}/*!    Static convenience function to get a floating point number from    the user. \a title is the text which is displayed in the title    bar of the dialog. \a label is the text which is shown to the user    (it should say what should be entered). \a value is the default    floating point number that the line edit will be set to. \a    minValue and \a maxValue are the minimum and maximum values the    user may choose, and \a decimals is the maximum number of decimal    places the number may have.    If \a ok is non-null, *\a ok will be set to true if the user    pressed \gui OK and to false if the user pressed \gui Cancel. The    dialog's parent is \a parent. The dialog will be modal and uses    the widget flags \a f.    This function returns the floating point number which has been    entered by the user.    Use this static function like this:    \quotefromfile dialogs/standarddialogs/dialog.cpp    \skipuntil Dialog::setDouble    \skipline {    \printto }    \sa getText(), getInteger(), getItem()*/double QInputDialog::getDouble( QWidget *parent, const QString &title, const QString &label,                                double value, double minValue, double maxValue,                                int decimals, bool *ok, Qt::WindowFlags f){    QInputDialogValidatedDoubleSpinBox *sb =        new QInputDialogValidatedDoubleSpinBox(minValue, maxValue, decimals, value);    QInputDialog dlg(title, label, parent, sb, f);    QObject::connect(        sb, SIGNAL(textChanged(bool)), qobject_cast<QPushButton*>(dlg.d_func()->okButton),        SLOT(setEnabled(bool)));    bool accepted = (dlg.exec() == QDialog::Accepted);    if (ok)        *ok = accepted;    return sb->value();}/*!    Static convenience function to let the user select an item from a    string list. \a title is the text which is displayed in the title    bar of the dialog. \a label is the text which is shown to the user (it    should say what should be entered). \a list is the    string list which is inserted into the combobox, and \a current is the number    of the item which should be the current item. If \a editable is true    the user can enter their own text; if \a editable is false the user    may only select one of the existing items.    If \a ok is non-null \e *\a ok will be set to true if the user    pressed \gui OK and to false if the user pressed \gui Cancel. The    dialog's parent is \a parent. The dialog will be modal and uses    the widget flags \a f.    This function returns the text of the current item, or if \a    editable is true, the current text of the combobox.    Use this static function like this:    \quotefromfile dialogs/standarddialogs/dialog.cpp    \skipuntil Dialog::setItem    \skipline {    \printto }    \sa getText(), getInteger(), getDouble()*/QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &list,                              int current, bool editable, bool *ok, Qt::WindowFlags f){    QComboBox *combo = new QComboBox;    combo->addItems(list);    combo->setCurrentIndex(current);    combo->setEditable(editable);    QInputDialog dlg(title, label, parent, combo, f);    bool accepted = (dlg.exec() == QDialog::Accepted);    if (ok)        *ok = accepted;    return combo->currentText();}/*!    \fn QString QInputDialog::getText(const QString &title, const QString &label,                                      QLineEdit::EchoMode echo = QLineEdit::Normal,                                      const QString &text = QString(), bool *ok = 0,                                      QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0)    Call getText(\a parent, \a title, \a label, \a echo, \a text, \a    ok, \a f) instead.    The \a name parameter is ignored.*//*!    \fn int QInputDialog::getInteger(const QString &title, const QString &label, int value = 0,                                     int minValue = -2147483647, int maxValue = 2147483647,                                     int step = 1, bool *ok = 0,                                     QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0)    Call getInteger(\a parent, \a title, \a label, \a value, \a    minValue, \a maxValue, \a step, \a ok, \a f) instead.    The \a name parameter is ignored.*//*!    \fn double QInputDialog::getDouble(const QString &title, const QString &label, double value = 0,                                       double minValue = -2147483647, double maxValue = 2147483647,                                       int decimals = 1, bool *ok = 0,                                       QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0)    Call getDouble(\a parent, \a title, \a label, \a value, \a    minValue, \a maxValue, \a decimals, \a ok, \a f).    The \a name parameter is ignored.*//*!    \fn QString QInputDialog::getItem(const QString &title, const QString &label, const QStringList &list,                                      int current = 0, bool editable = true, bool *ok = 0,                                      QWidget *parent = 0, const char *name = 0, Qt::WindowFlags f = 0)    Call getItem(\a parent, \a title, \a label, \a list, \a current,    \a editable, \a ok, \a f) instead.    The \a name parameter is ignored.*/#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -