O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

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 – Downloading a file

Create a Qt Widgets project and add a widget class named FileDownload. Add a button that will start the download and a plain text edit that will display the result. As always, you can look at the code files provided with the book if you need any help.

Next, enable the Qt Network module by adding QT += network to the project file. Then, create an instance of QNetworkAccessManager in the constructor and put it in a private field:

m_network_manager = new QNetworkAccessManager(this); 

Since QNetworkAccessManager inherits QObject, it takes a pointer to QObject, which is used as a parent. Thus, you do not have delete the manager later on.

Secondly, we connect the manager's finished() signal to a slot of our ...

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