http默认的是异步请求方式。
如何实现同步http请求:
使用自己创建的事件循环QEventLoop实例。
m_pTimeOut->start(timeOut);
m_pEventLoop->exec();//当前主线程会暂停在这里。直到QEventLoop实例退出,才继续执行。
QEventLoop退出的条件:
1.超时
在定时器的OnTimeOut()方法中,退出QEventLoop
2.
http请求完成,
在OnFinished()方法中,退出QEventLoop