O'Reilly logo

Qt 5 Projects by Marco Piccolino

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

Performing the HTTP request and consuming the response

The HTTP request is issued in the receiveReadings slot. Being an asynchronous request, we will have to consume the reply in the _replyFinished slot after issuing the request. Another thing we might want to do is extract the address of the HTTP server to be called from the method implementations and define it in a static constant at the top of the file instead. This will make it easier to change it whenever we want to:

// receiver_http.cpp#include "receiver_http.h"#include <QVariantList>#include <QNetworkAccessManager>#include <QNetworkReply>namespace channels {static const QUrl broadcasterHttpUrl("http://127.0.0.1:8081");}...void channels::ReceiverHttp::receiveReadings(){ if (_nam) _nam->get(QNetworkRequest(channels::broadcasterHttpUrl)); ...

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