The readyRead signal

Until now, we have used the slot connected to the finished() signal to get the reply's content. This works perfectly if you are deal with small files. However, this approach is unsuitable when dealing with large files, as they will unnecessarily bind too many resources. For larger files, it is better to read and save the transferred data as soon as it is available. We are informed by QIODevice::readyRead() whenever new data is available to be read. So, for large files, you should use the following code:

QNetworkReply *reply = m_network_manager->get(request);connect(reply, &QIODevice::readyRead,
        this, &SomeClass::readContent);
m_file.open(QIODevice::WriteOnly); 

This will help you connect the reply's readyRead() signal ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition 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.