Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-On GUI Programming with C++ and Qt5

You're reading from   Hands-On GUI Programming with C++ and Qt5 Build stunning cross-platform applications and widgets with the most powerful GUI framework

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher Packt
ISBN-13 9781788397827
Length 404 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Eng Eng
Author Profile Icon Eng
Eng
Lee  Z Eng Lee Z Eng
Author Profile Icon Lee Z Eng
Lee Z Eng
Arrow right icon
View More author details
Toc

Table of Contents (23) Chapters Close

Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
1. Introduction to Qt FREE CHAPTER 2. Qt Widgets and Style Sheets 3. Database Connection 4. Graphs and Charts 5. Item Views and Dialogs 6. Integrating Web Content 7. Map Viewer 8. Graphics View 9. The Camera Module 10. Instant Messaging 11. Implementing a Graphics Editor 12. Cloud Storage 13. Multimedia Viewers 14. Qt Quick and QML 15. Cross-Platform Development 16. Testing and Debugging 1. Other Books You May Enjoy Index

Preface

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 how to design and build graphical user interfaces that are functional, appealing, and user-friendly.

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.

Who this book is for

This book will appeal to developers and programmers who would like to build GUI-based applications. Basic knowledge of C++ is necessary, and the basics of Qt would be helpful.

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.

To get the most out of this book

In order to successfully execute all the codes and instructions in this book, you would need  the following:

  • A basic PC/Laptop
  • A working internet connection
  • Qt 5.10
  • MariaDB 10.2 (or MySQL Connector)
  • Filezilla Server 0.9

We will deal with the installation processes and details as we go through each chapter.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-GUI-Programming-with-CPP-and-Qt5 In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/HandsOnGUIProgrammingwithCPPandQt5_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "We call the test() function at the MainWindow constructor."

A block of code is set as follows:

void MainWindow::test() 
{ 
   int amount = 100; 
   amount -= 10; 
   qDebug() << "You have obtained" << amount << "apples!"; 
} 

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

MainWindow::MainWindow(QWidget *parent) : 
   QMainWindow(parent), 
   ui(new Ui::MainWindow) 
{ 
   ui->setupUi(this); 
   test(); 
} 

Any command-line input or output is written as follows:

********* Start testing of MainWindow ********* 
Config: Using QtTest library 5.9.1, Qt 5.9.1 (i386-little_endian-ilp32 shared (dynamic) debug build; by GCC 5.3.0) 
PASS   : MainWindow::initTestCase() 
PASS   : MainWindow::_q_showIfNotHidden() 
PASS   : MainWindow::testString() 
PASS   : MainWindow::testGui() 
PASS   : MainWindow::cleanupTestCase() 
Totals: 5 passed, 0 failed, 0 skipped, 0 blacklisted, 880ms 
********* Finished testing of MainWindow *********

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "The third option is Toggle Bookmark, which lets you set a bookmark for your own reference."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

 

 

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images