7#include <QtCore/QJsonDocument>
8#include <QtCore/QJsonObject>
9#include <QtCore/QJsonArray>
10#include <QtPositioning/QGeoCoordinate>
11#include <QtPositioning/QGeoAddress>
12#include <QtPositioning/QGeoLocation>
13#include <QtPositioning/QGeoRectangle>
22 setError(UnknownError, QStringLiteral(
"Null reply"));
26 connect(reply, &QNetworkReply::finished,
this, &QGeoCodeReplyMapbox::onNetworkReplyFinished);
27 connect(reply, &QNetworkReply::errorOccurred,
this, &QGeoCodeReplyMapbox::onNetworkReplyError);
29 connect(
this, &QGeoCodeReply::aborted, reply, &QNetworkReply::abort);
30 connect(
this, &QObject::destroyed, reply, &QObject::deleteLater);
33QGeoCodeReplyMapbox::~QGeoCodeReplyMapbox()
37void QGeoCodeReplyMapbox::onNetworkReplyFinished()
39 QNetworkReply *reply =
static_cast<QNetworkReply *>(sender());
42 if (reply->error() != QNetworkReply::NoError)
45 QList<QGeoLocation> locations;
46 QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
47 if (!document.isObject()) {
48 setError(ParseError, tr(
"Response parse error"));
52 const QJsonArray features = document.object().value(QStringLiteral(
"features")).toArray();
53 for (
const QJsonValueConstRef value : features)
54 locations.append(QMapboxCommon::parseGeoLocation(value.toObject()));
56 setLocations(locations);
61void QGeoCodeReplyMapbox::onNetworkReplyError(QNetworkReply::NetworkError error)
64 QNetworkReply *reply =
static_cast<QNetworkReply *>(sender());
66 setError(QGeoCodeReply::CommunicationError, reply->errorString());
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
Combined button and popup list for selecting options.
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)