Below is the implementation of QInputDialog::getText from Qt 4.7
Qt::WindowFlags flags)
{
dialog.setWindowTitle(title);
dialog.setLabelText(label);
dialog.setTextValue(text);
dialog.setTextEchoMode(mode);
int ret = dialog.exec();
if (ok)
*ok = !!ret;
if (ret) {
return dialog.textValue();
} else {
}
}
QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode mode, const QString &text, bool *ok,
Qt::WindowFlags flags)
{
QInputDialog dialog(parent, flags);
dialog.setWindowTitle(title);
dialog.setLabelText(label);
dialog.setTextValue(text);
dialog.setTextEchoMode(mode);
int ret = dialog.exec();
if (ok)
*ok = !!ret;
if (ret) {
return dialog.textValue();
} else {
return QString();
}
}
To copy to clipboard, switch view to plain text mode
My question is about line 13. First I thought !! is used to convert int to bool, but soon I realized the conversion takes place automatically. Is it something special about !! ?
Bookmarks