The tutorial doesn't tell you the whole story.
The code in section Usage is supposed to be part of a class MainWindow
– the controller of your main window (see line 1 of tutorial's last snippet). This class contains a slot loadImaged()
called when the NetworkReply has finished. It also has a member FileDownloader * m_pImgCtrl
.
For instance, the second Usage snippet could be part of a slot MainWindow::buttonClicked()
like
void MainWindow::buttonClicked()
{
QUrl imageUrl("http://qt.digia.com/Documents/1/QtLogo.png");
m_pImgCtrl = new FileDownloader(imageUrl, this);
connect(m_pImgCtrl, SIGNAL(downloaded()), SLOT(loadImage()));
}