Book Image

Hands-On GUI Programming with C++ and Qt5

By : Lee Zhi Eng
Book Image

Hands-On GUI Programming with C++ and Qt5

By: Lee Zhi Eng

Overview of this book

Qt 5, the latest version of Qt, enables you to develop applications with complex user interfaces for multiple targets. It provides you with faster and smarter ways to create modern UIs and applications for multiple platforms. This book will teach you to design and build graphical user interfaces that are functional, appealing, and user-friendly. In the initial part of the book, you will learn what Qt 5 is and what you can do with it. You will explore the Qt Designer, discover the different types of widgets generally used in Qt 5, and then connect your application to the database to perform dynamic operations. Next, you will be introduced to Qt 5 chart which allows you to easily render different types of graphs and charts and incorporate List View Widgets in your application. You will also work with various Qt modules, like QtLocation, QtWebEngine, and the networking module through the course of the book. Finally, we will focus on cross-platform development with QT 5 that enables you to code once and run it everywhere, including mobile platforms. By the end of this book, you will have successfully learned about high-end GUI applications and will be capable of building many more powerful, cross-platform applications.
Table of Contents (18 chapters)

What this book covers

Chapter 1, Introduction to Qt, will give you a tour of Qt. In this book, you'll download the SDK, install Qt, and, most importantly, install Qt Creator, which is used as both the user interface designer and the IDE for writing and compiling C++ scripts.

Chapter 2, Qt Widgets and Style Sheets, will introduce you to the different types of widgets generally used in Qt to develop desktop applications. You will learn the first step to create your own application, which uses all kinds of widgets and customizations, using the powerful style sheet mechanism provided by Qt, which is very similar to CSS for web.

Chapter 3, Database Connection, will introduce you to the MariaDB database and teach you how to connect to it using Qt. You will first learn what is MariaDB database and how to call simple SQL commands to fetch and insert data into a MariaDB database. We will then create a simple but fully functional login page.

Chapter 4, Graphs and Charts, explores the Chart feature to allow users to easily render different types of graphs and charts, such as pie chart, bar chart, and line graph. We will make use of the knowledge learned from this chapter to create a dashboard page for an application, which displays all kinds of statistical summary of their company and business.

Chapter 5, Item Views and Dialogs, will teach you how to display a list of information by using three different item view widgets—a list widget, tree widget, and table widget. You will also learn how to prompt a message box to display error messages, warnings, and confirmation. You will then create an application that can load, scale, and crop images.

Chapter 6, Integrating Web Content, will empower you to use the Qt WebEngine module and make a simple web browser, which displays a web page. We will then go through what is sessions, cookies, and cache and subsequently how to manage them with Qt WebEngine. Finally, you will learn how to make your C++ code communicate with JavaScript content through the WebChannel mechanism.

Chapter 7, Map Viewer, will focus on creating a map display. This map will be used to display the location of places and people. You will learn how to implement the QtLocation module, understand the coordinate system, display location markers on the map, and so on.

Chapter 8, Graphics View, will provide a platform to manage and interact with a large number of custom-made graphical items and a view widget to visualize the items with support for zooming and rotation. You will learn how to make an organization's chart page that displays the structure of an organization and the relationships and relative ranks of its parts and positions/jobs.

Chapter 9, The Camera Module, will explore how to display camera images using Qt. Qt provides us with a multimedia module that enables us to easily take advantage of a platform's multimedia capabilities, such as connecting to the camera of the computer.

Chapter 10, Instant Messaging, will discuss the networking module and help us to make our own simple instant messaging program.

Chapter 11, Implementing a Graphics Editor, is divided into two sections, based on the two types of graphics in the rendering world–bitmap graphics and vector graphics. Both are quite different but essential to learning in order to understand 2D graphics rendering. You will learn how to draw graphics using Qt in this chapter.

Chapter 12, Cloud Storage, will teach you how to upload different types of files to the FTP server and display them in a list. The user will be able to download the file and open them with different types of viewers depending on its file format.

Chapter 13, Multimedia Viewers, will deal with creating a media player instead of using the default software on your computer. In this chapter, you will learn how to create an image viewer, a music player, and a video player.

Chapter 14, Qt Quick and QML, will introduce you to the basics of QML scripting, which is one of the most recent trends in the Qt world.

Chapter 15, Cross-Platform Development, will show you how to export applications to different platforms without re-writing the code from scratch. You will learn some of the essential settings and tips to look out for when porting applications to different platforms. Besides PC platforms, you will also learn how to export applications to mobile platforms.

Chapter 16, Testing and Debugging, will teach you the essentials of how to use various techniques to test and debug your Qt application.