Results 1 to 2 of 2

Thread: Change QHttp:: state() from unconnected to connected

  1. #1
    Join Date
    Nov 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Angry Change QHttp:: state() from unconnected to connected

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Change QHttp:: state() from unconnected to connected

    QHttp works in asynchronous way. You have to wait before the connection is actually made as setHost() only schedules the connection. Similarily post() only queues the actual POST request that will be made after QHttp manages to connect to the host.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Handling window state change
    By sudhansu in forum Qt Programming
    Replies: 0
    Last Post: 10th November 2010, 12:28
  2. Change position according to QCheckBox State
    By champ in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2010, 18:37
  3. Replies: 1
    Last Post: 11th December 2009, 17:21
  4. Replies: 11
    Last Post: 20th January 2009, 14:10
  5. Difference between QHttp::get and QHttp.request
    By LMZ in forum Qt Programming
    Replies: 2
    Last Post: 6th September 2007, 16:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.