Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Change QHttp:: state() from unconnected to connected
Forum Updated to NodeBB v4.3 + New Features

Change QHttp:: state() from unconnected to connected

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 3 Posters 3.5k 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.
  • E Offline
    E Offline
    eman.refaat
    wrote on last edited by
    #1

    I try to write program which handle web service using QHttp :: Post().
    When i click on button ,it will sent post request.
    but the QHttp :: state() =Unconnected.
    [Code :]

    void MainWindow::LogIn()
    {
    ui->btnLogin->setEnabled(false);
    QUrl url;
    url.setPath("path of API");
    QByteArray data("username=");
    data.append(ui->txtUserName->text());
    data.append("&password=");
    data.append(ui->txtPassword->text());
    http->setHost("Website.com");
    int result= http->post(url.toString(),data);//note result =2
    http->state();//note state = Unconnected
    }
    how can change state of http to connect ???

    Thank you for your help.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      blex
      wrote on last edited by
      #2

      As far as I know the http->post() is non-blocking call. So, operation still in progress. Try to connect to your "http" object signals and you will be notified about state change.


      Oleksiy Balabay

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tony
        wrote on last edited by
        #3

        Hi,

        in any case, I suggest you to use QNetworkAccessManager. QHttp has been deprecated.

        T.

        1 Reply Last reply
        0
        • E Offline
          E Offline
          eman.refaat
          wrote on last edited by
          #4

          Thank blex and Antonio very much, I try to connect with done() and it's connect.

          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