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 ...

Get Game Programming Using Qt now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.