O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hands-On GUI Programming with C++ and Qt5

Book Description

Create visually appealing and feature-rich applications by using Qt 5 and the C++ language

About This Book
  • Explore Qt 5's powerful features to easily design your GUI application
  • Leverage Qt 5 to build attractive cross-platform applications
  • Work with Qt modules for multimedia, networking, and location, to customize your Qt 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 You Will Learn
  • Implement tools provided by Qt 5 to design a beautiful GUI
  • Understand different types of graphs and charts supported by Qt 5
  • Create a web browser using the Qt 5 WebEngine module and web view widget
  • Connect to the MySQL database and display data obtained from it onto the Qt 5 GUI
  • Incorporate the Qt 5 multimedia and networking module in your application
  • Develop Google Map-like applications using Qt 5's location module
  • Discover cross-platform development by exporting the Qt 5 application to different platforms
  • Uncover the secrets behind debugging Qt 5 and C++ applications
In Detail

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.

Style and approach

This is a comprehensive guide that explores the essential Qt features and implement them in building real-world cross-platform GUI applications

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On GUI Programming with C++ and Qt5
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Introduction to Qt
    1. What is Qt?
      1. Why use Qt?
      2. Discovering tools in Qt
        1. Qt Designer
        2. Qt Quick Designer
    2. Downloading and installing Qt
      1. Setting up the working environment
    3. Running our first Hello World Qt program
    4. Summary
  7. Qt Widgets and Style Sheets
    1. Introduction to Qt Designer
    2. Basic Qt widgets
    3. Qt Style Sheets
    4. Summary
  8. Database Connection
    1. Introducing the MySQL database system
    2. Setting up the MySQL database
    3. SQL commands
      1. SELECT
      2. INSERT
      3. UPDATE
      4. DELETE
      5. JOIN
    4. Database connection in Qt
    5. Creating our functional login page
    6. Summary
  9. Graphs and Charts
    1. Types of charts and graphs in Qt
      1. Line and spline charts
      2. Bar charts
      3. Pie charts
      4. Polar charts
      5. Area and scatter charts
      6. Box-and-whiskers charts
      7. Candlestick charts
    2. Implementing charts and graphs
    3. Creating the dashboard page
    4. Summary
  10. Item Views and Dialogs
    1. Working with item view widgets
      1. Creating our Qt Widgets application
        1. Making our List Widget functional
        2. Adding functionality to the Tree Widget
        3. Finally, our Table Widget
    2. Working with dialog boxes
    3. Creating File Selection Dialogs
    4. Image scaling and cropping
    5. Summary
  11. Integrating Web Content
    1. Creating your own web browser
      1. Adding the web view widget
      2. Creating a UI for a web browser
      3. Managing browser history
    2. Sessions, cookies, and cache
      1. Managing sessions and cookies
      2. Managing cache
    3. Integrating JavaScript and C++
      1. Calling JavaScript functions from C++
      2. Calling C++ functions from JavaScript
    4. Summary
  12. Map Viewer
    1. Map display
      1. Setting up the Qt location module
      2. Creating a map display
    2. Marker and shape display
      1. Displaying position markers on a map
      2. Displaying shapes on a map
    3. Obtaining a user's location
    4. Geo Routing Request
    5. Summary
  13. Graphics View
    1. Graphics View framework
      1. Setting up a new project
      2. Movable graphics items
      3. Creating an organization chart
    2. Summary
  14. The Camera Module
    1. The Qt multimedia module
      1. Setting up a new project
    2. Connecting to the camera
    3. Capturing a camera image to file
    4. Recording a camera video to file
    5. Summary
  15. Instant Messaging
    1. The Qt networking module
      1. Connection protocols
      2. Setting up a new project
    2. Creating an instant messaging server
      1. Creating TCP Server
      2. Listening to clients
    3. Creating an instant messaging client
      1. Designing the user interface
      2. Implementing chat features
    4. Summary
  16. Implementing a Graphics Editor
    1. Drawing vector shapes
      1. Vector versus bitmap
      2. Drawing vector shapes using QPainter
      3. Drawing text
    2. Saving vector images to an SVG File
    3. Creating a paint program
      1. Setting up a user interface
    4. Summary
  17. Cloud Storage
    1. Setting up the FTP server
      1. Introducing FTP
      2. Downloading FileZilla
      3. Setting up FileZilla
    2. Displaying the file list on the list view
      1. Setting up a project
      2. Setting up user interface
      3. Displaying the file list
      4. Writing the code
    3. Uploading files to the FTP server
    4. Downloading files from the FTP server
    5. Summary
  18. Multimedia Viewers
    1. Revisiting the multimedia module
      1. Dissecting the module
    2. The image viewer
      1. Designing a user interface for the image viewer
      2. Writing C++ code for image viewers
    3. The music player
      1. Designing a user interface for music players
      2. Writing C++ code for music players
    4. The video player
      1. Designing a user interface for video players
      2. Writing C++ code for video players
    5. Summary
  19. Qt Quick and QML
    1. Introduction to Qt Quick and QML
      1. Introducing Qt Quick
      2. Introducing QML
    2. Qt Quick widgets and controls
    3. Qt Quick Designer
    4. Qt Quick layouts
    5. Basic QML scripting
      1. Setting up the project
    6. Summary
  20. Cross-Platform Development
    1. Understanding compilers
      1. What is a compiler?
      2. Build automation with Make
    2. Build settings
      1. Qt Project (.pro) File
      2. Comment
      3. Modules, configurations, and definitions
      4. Platform-specific settings
    3. Deploying to PC platforms
      1. Windows
      2. Linux
      3. macOS
    4. Deploying to mobile platforms
      1. iOS
      2. Android
    5. Summary
  21. Testing and Debugging
    1. Debugging techniques
      1. Identifying the problem
      2. Print variables using QDebug
      3. Setting breakpoints
    2. Debuggers supported by Qt
      1. Debugging for PC
      2. Debugging for Android devices
      3. Debugging for macOS and iOS
    3. Unit testing
      1. Unit testing in Qt
    4. Summary
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think