Using Google’s Geocoding API
In this example, we will learn how to obtain the full address of a specific location by using Google’s Geocoding API.
How to do it…
Let’s create a program that utilizes the Geocoding API by following these steps:
- Create a new Qt Widgets Application project.
- Open
mainwindow.ui
and add a couple of text labels, input fields, and a button to make your UI look similar to this:
Figure 10.7 – Setting up your UI
- Open your project (
.pro
) file and add the network module to your project. You can do that by simply adding the wordnetwork
aftercore
andgui
, as shown in the following code:QT += core gui network
- Open
mainwindow.h
and add the following headers to the source code:#include <QMainWindow> #include <QDebug> #include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkReply> #include <QJsonDocument> #include <QJsonArray>...