#include #include #include #include #include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QNetworkAccessManager nam; auto authProvided = false; QObject::connect(&nam, &QNetworkAccessManager::authenticationRequired, [&](QNetworkReply *reply, QAuthenticator *authenticator) { if (!authProvided) { auto realm = authenticator->realm(); authenticator->setUser("ftptester"); authenticator->setPassword("OhBaifalee8m"); authProvided = true; } }); QNetworkRequest request( QUrl("ftp://208.88.224.211:21/testfile128")); auto reply = nam.get(request); QObject::connect(reply, &QNetworkReply::finished, [=]() { auto error = reply->error(); auto errStr = reply->errorString(); auto ok = error == QNetworkReply::NoError; QCoreApplication::quit(); }); return a.exec(); }