Book Image

Qt5 C++ GUI Programming Cookbook

By : Lee Zhi Eng
Book Image

Qt5 C++ GUI Programming Cookbook

By: Lee Zhi Eng

Overview of this book

With the advancement of computer technology, the software market is exploding with tons of software choices for the user, making their expectations higher in terms of functionality and the look and feel of the application. Therefore, improving the visual quality of your application is vital in order to overcome the market competition and stand out from the crowd. This book will teach you how to develop functional and appealing software using Qt5 through multiple projects that are interesting and fun. This book covers a variety of topics such as look-and-feel customization, GUI animation, graphics rendering, implementing Google Maps, and more. You will learn tons of useful information, and enjoy the process of working on the creative projects provided in this book
Table of Contents (16 chapters)
Qt5 C++ GUI Programming Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

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:

  1. First, create a new Qt Widgets Application project.

  2. Next, open up mainwindow.ui and add a couple of text labels, input fields, and a button to make your UI to look similar to this:

  3. After that, open up your project (.pro) file and add the network module to your project. You can do that by simply adding the network text after core and gui, like so:

    QT += core gui network
  4. Then, open up mainwindow.h and add the following headers to the source code, right after the line #include <QMainWindow>:

    #include <QDebug>
    #include <QtNetwork/QNetworkAccessManager>
    #include <QtNetwork/QNetworkReply>
    #include <QXmlStreamReader>
  5. Next, declare a slot function manually and call it getAddressFinished():

    private slots:
      void getAddressFinished(QNetworkReply...