Qt synchronous QNetworkAccessManager

What is the correct way to execute synchronous QNetworkAccessManager :: get?

The qt wiki offers an approach, but indicates that "this is not recommended for use in real applications." the mailing list offers a similar solution for the wiki.

+4
source share
2 answers

Yum might use something like this:

QEventLoop loop; connect(_netReply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); 
+3
source

The simple solution mentioned in the wiki and in the answer from yttrium is rather fragile, because it does not handle all possible failure scenarios (for example, proxies) and therefore should not be used in a production environment, and, unfortunately, it has become more prolific, therefore anyone who asks for synchronous QNAM just gets a dead end from "using it asynchronously [silly]" or this simple piece of code that will ultimately fail.

I did not find the β€œright” solution made by the Qt team, but this guy on codeproject was decent enough to make a more comprehensive shell that should be much more secure:
http://www.codeproject.com/Articles/484905/Use-QNetworkAccessManager-for-synchronous-download

+1
source

All Articles