how to check whether we logged into the server or not using QtNetworkAccessManager?
-
I have a Qt Application in which i tried to log into a server . I am using QNetworkAccessmanager. I have tried the following code
QNetworkAccessManager* networkaccess = new QNetworkAccessManager();
QUrl url2("//My server IP Address");
url2.setUserName("server UserName");
url2.setPassword(" server Password");
QNetworkRequest req(url2);
QNetworkReply* reply = networkaccess->get(req);
if (reply->error() == QNetworkReply::NoError)
{
If i give wrong password also it enters here
}Is there any other way to check whether the server is logged on?
-
@Selvajothi said in how to check whether we logged into the server or not using QtNetworkAccessManager?:
QNetworkReply* reply = networkaccess->get(req);
if (reply->error() == QNetworkReply::NoError)
{Networking does not work like this. After sending GET request you need to "wait" for response or error, you can't just ask error status immediately after sending GET request. Please check documentation, there is even an example: https://doc.qt.io/qt-5/qnetworkaccessmanager.html
-
thank you