7#include <QtCore/QJsonDocument>
8#include <QtCore/QJsonArray>
9#include <QtCore/QJsonObject>
10#include <QtNetwork/QNetworkReply>
11#include <QtPositioning/QGeoCircle>
12#include <QtPositioning/QGeoRectangle>
13#include <QtLocation/QPlaceResult>
14#include <QtLocation/QPlaceSearchRequest>
23 setError(UnknownError, QStringLiteral(
"Null reply"));
27 connect(reply, &QNetworkReply::finished,
this, &QPlaceSearchSuggestionReplyMapbox::onReplyFinished);
28 connect(reply, &QNetworkReply::errorOccurred,
this, &QPlaceSearchSuggestionReplyMapbox::onNetworkError);
30 connect(
this, &QPlaceReply::aborted, reply, &QNetworkReply::abort);
31 connect(
this, &QObject::destroyed, reply, &QObject::deleteLater);
40 QPlaceReply::setError(errorCode, errorString);
41 emit errorOccurred(errorCode, errorString);
49 QNetworkReply *reply =
static_cast<QNetworkReply *>(sender());
52 if (reply->error() != QNetworkReply::NoError)
55 QJsonDocument document = QJsonDocument::fromJson(reply->readAll());
56 if (!document.isObject()) {
57 setError(ParseError, tr(
"Response parse error"));
61 const QJsonArray features = document.object().value(QStringLiteral(
"features")).toArray();
63 QStringList suggestions;
64 for (
const QJsonValueConstRef feature : features) {
65 if (feature.isObject())
66 suggestions.append(feature.toObject().value(QStringLiteral(
"text")).toString());
69 setSuggestions(suggestions);
78 QNetworkReply *reply =
static_cast<QNetworkReply *>(sender());
80 setError(CommunicationError, reply->errorString());
The QNetworkReply class contains the data and headers for a request sent with QNetworkAccessManager.
~QPlaceSearchSuggestionReplyMapbox()
Combined button and popup list for selecting options.
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)