O'Reilly logo

Game Programming Using Qt by Lorenz Haas, Witold Wysota

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – displaying a proper error message

Fortunately, QNetworkReply offers several possibilities to do this. In the slot called downloadFinished(), we first want to check whether an error occurred:

if (reply->error() != QNetworkReply::NoError) {/* error occurred */}

The QNetworkReply::error() function returns the error that occurred while handling the request. The error is encoded as a value of the QNetworkReply::NetworkError type. The two most common errors are probably these:

Error code

Meaning

ContentNotFoundError

This error indicates that the URL of the request could not be found. It is similar to the HTTP error code 404.

ContentAccessDenied

This error indicates that you do not have the permission to access the requested ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required