First of all I'm trying perform synchronous HTTP requests. QNetworkAccessManager doesn't seem to offer support for it, so I'm trying to emulate this with a separate event loop.

Qt Code:
  1. QNetworkAccessManager NAManager;
  2. QUrl url ("http://www.google.com");
  3. QNetworkRequest request(url);
  4. QNetworkReply *reply = NAManager.get(request);
  5. QEventLoop eventLoop;
  6. QObject::connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
  7. eventLoop.exec();
  8. std::cout << "finished" << std::endl; //request finished here
To copy to clipboard, switch view to plain text mode 

Question: is there a nicer way to achieve this?

Another question: is it possible to create an event loop that allows you to manually post events to it?