不成功的方式: 1. QNetworkReply的isFinished()函数, 通过while循环判断reply是否已经结束, 结束后再调用readAll()读取响应信息, 结果与判断isRunning() 方式结果一样, 都会进入死循环, 没有响应. 2. QNetworkReply继承自QIODevice, 尝试调用QIODevice的waitForReadyRead()方法, 结果不阻塞, 直接返回
成功的方式: 使用QEventLoop来阻塞运行, 知道信号发出
QNetworkReply *reply = _manager->post(QNetworkRequest(QUrl(SERVER_URL)), data);
QByteArray responseData;
QEventLoop eventLoop;
connect(_manager, SIGNAL(finished(QNetworkReply*)), &eventLoop, SLOT(quit()));
eventLoop.exec(); //block until finish
responseData = reply->readAll();