Reader small image

You're reading from  Qt 6 C++ GUI Programming Cookbook - Third Edition

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781805122630
Edition3rd Edition
Right arrow
Author (1)
Lee Zhi Eng
Lee Zhi Eng
author image
Lee Zhi Eng

Lee Zhi Eng is a self-taught programmer who worked as an artist and programmer at several game studios before becoming a part-time lecturer for 2 years at a university, teaching game development subjects related to Unity and Unreal Engine. He has not only taken part in various projects related to games, interactive apps, and virtual reality but has also participated in multiple projects that are more oriented toward software and system development. When he is not writing code, he enjoys traveling, photography, and exploring new technologies.
Read more about Lee Zhi Eng

Right arrow

Embedding Google maps in your project

In this recipe, we will learn how to embed Google maps in our project through Qt’s WebEngine module. This example doesn’t focus much on Qt and C++, but rather on the Google Maps API in HTML code.

How to do it…

Let’s create a program that displays Google maps by following these steps:

  1. Create a new Qt Widgets Application project and remove the statusBar, menuBar, and mainToolBar objects.
  2. Open your project file (.pro) and add the following modules to your project:
    QT += core gui webenginewidgets
  3. Open mainwindow.ui and add a vertical layout to the canvas. Then, select the canvas and click the Lay Out Vertically button on top of the canvas. You will get the following:
Figure 13.14 – Adding a vertical layout to the central widget

Figure 13.14 – Adding a vertical layout to the central widget

  1. Open mainwindow.cpp and add the following header to the top of the source code:
    #include <QtWebEngineWidgets/QWebEngineView>
  2. ...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Qt 6 C++ GUI Programming Cookbook - Third Edition
Published in: Apr 2024Publisher: PacktISBN-13: 9781805122630

Author (1)

author image
Lee Zhi Eng

Lee Zhi Eng is a self-taught programmer who worked as an artist and programmer at several game studios before becoming a part-time lecturer for 2 years at a university, teaching game development subjects related to Unity and Unreal Engine. He has not only taken part in various projects related to games, interactive apps, and virtual reality but has also participated in multiple projects that are more oriented toward software and system development. When he is not writing code, he enjoys traveling, photography, and exploring new technologies.
Read more about Lee Zhi Eng