problem with Synchronous Http request
HI,
I am using Qt-extended4.43.
i am trying to make synchronous http connection.but its not connecting.
Can any one help me?
Here is the sample code.
Code:
bool syncPostURL( const QUrl& url, const QByteArray& data) {
///connect the requestFinished signal to our finished slot
connect(this,SIGNAL(requestFinished(int,bool)),SLOT(finished (int,bool)));
header.setContentType("application/x-www-form-urlencoded");
header.setValue("Host", url.host());
/// start the request and store the requestID
requestID = request(header,data);
/// block until the request is finished
loop.exec();
/// return the request status
return status;
}
virtual void finished ( int idx, bool err )
{
/// check to see if it's the request we made
if ( idx!=requestID )
return;
/// set status of the request
status = !err;
/// end the loop
loop.exit();
}
Re: problem with Synchronous Http request
The loop will exit on the first request being finished and the first request is a call to setHost(). Connect to done() instead.
Re: problem with Synchronous Http request
Thanx for the reply.............Now, My next question is
Above code is working in QtEmbedded as well as Qt -X11.
But it is not connecting in QT Extended.
The only difference is in writing the main() function.
In Qt Extended the main() function is
QTOPIA_ADD_APPLICATION(QTOPIA_TARGET, MYCLASS)
QTOPIA_MAIN
In Qt X11 and Qt-Embeded the main function is
int main(int argc , char * argv[])
{ QApplication app (argc, argv);
MYCLASS obj;
return app.exec()
}