QNetworkAccessManager netMan;
QNetworkReply
* const repl
= netMan.
get(QNetworkRequest
(QUrl::fromUserInput("ftp url direct to file")));
QObject::connect(repl,
&QNetworkReply
::readyRead,
[repl
]()->void
{qDebug
().
noquote() << repl
->readAll
();
});
QObject::connect(repl,QOverload<QNetworkReply
::NetworkError>
::of(&QNetworkReply
::error),
[repl
]()->void
{qDebug
() <<
"Error: " + repl
->errorString
();
});
QObject::connect(repl,
&QNetworkReply
::finished,repl,
&QNetworkReply
::deleteLater);
QObject::connect(&netMan,
&QNetworkAccessManager
::authenticationRequired,repl,
[repl
](QNetworkReply
*reply, QAuthenticator
*authenticator
)->void
{ if(reply!=repl)
return;
authenticator->setUser(" ");
authenticator->setPassword(" ");
});
QNetworkAccessManager netMan;
QNetworkReply* const repl = netMan.get(QNetworkRequest(QUrl::fromUserInput("ftp url direct to file")));
QObject::connect(repl,&QNetworkReply::readyRead,[repl]()->void{qDebug().noquote() << repl->readAll();});
QObject::connect(repl,QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error),[repl]()->void{qDebug() << "Error: " + repl->errorString();});
QObject::connect(repl,&QNetworkReply::finished,repl,&QNetworkReply::deleteLater);
QObject::connect(&netMan,&QNetworkAccessManager::authenticationRequired,repl,[repl](QNetworkReply *reply, QAuthenticator *authenticator)->void{
if(reply!=repl)
return;
authenticator->setUser(" ");
authenticator->setPassword(" ");
});
To copy to clipboard, switch view to plain text mode
Bookmarks