Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to check whether we logged into the server or not using QtNetworkAccessManager?
Forum Updated to NodeBB v4.3 + New Features

how to check whether we logged into the server or not using QtNetworkAccessManager?

Scheduled Pinned Locked Moved Solved General and Desktop
qt5
3 Posts 2 Posters 344 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Selvajothi
    wrote on last edited by
    #1

    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?

    jsulmJ 1 Reply Last reply
    0
    • S Selvajothi

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • S Offline
        S Offline
        Selvajothi
        wrote on last edited by
        #3

        thank you

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved