blob: 5a527e18db1ef90341dab0e4bf4d2e6006bd6d0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QApplication>
#include <QInputDialog>
#include <QTimer>
#include <iostream>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QTimer::singleShot(0, [] {
QInputDialog dlg;
const QStringList appArgs = qApp->arguments();
QString labelText = QCoreApplication::translate("qtc-askpass",
"Password required.");
if (appArgs.count() > 1)
labelText.append('\n').append(appArgs.at(1));
dlg.setLabelText(labelText);
dlg.setTextEchoMode(QLineEdit::Password);
if (dlg.exec() == QDialog::Accepted)
std::cout << qPrintable(dlg.textValue()) << std::endl;
});
return app.exec();
}
|