Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QString QInputDialog::getText ( QWidget parent,
const QString title,
const QString label,
QLineEdit::EchoMode  mode = QLineEdit::Normal,
const QString text = QString(),
bool *  ok = 0,
Qt::WindowFlags  f = 0 
) [static]

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. The mode is the echo mode the line edit will use. If ok is non-null *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 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:

examples/dialogs/standarddialogs/dialog.cpp 3

See also:
getInteger(), getDouble(), getItem()

Definition at line 386 of file qinputdialog.cpp.

References QDialog::accepted(), QDialog::exec(), QDialog::result(), QLineEdit::selectAll(), QLineEdit::setEchoMode(), QWidget::setFocus(), QLineEdit::setText(), and QLineEdit::text.

Referenced by MainWindow::findItems(), BasicToolsPlugin::generateShape(), MainWindow::insertItem(), QWebPage::javaScriptPrompt(), MainWindow::openUrl(), and Dialog::setText().

    QLineEdit *le = new QLineEdit;

    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;

Generated by  Doxygen 1.6.0   Back to index