0%

Enhance your cross-platform programming abilities with the powerful features and capabilities of Qt 6

Key Features

  • Leverage Qt and C++ capabilities to create modern, cross-platform applications that can run on a wide variety of software applications
  • Explore what's new in Qt 6 and understand core concepts in depth
  • Build professional customized GUI applications with the help of Qt Creator

Book Description

Qt is a cross-platform application development framework widely used for developing applications that can run on a wide range of hardware platforms with little to no change in the underlying codebase. If you have basic knowledge of C++ and want to build desktop or mobile applications with a modern graphical user interface (GUI), Qt is the right choice for you. Cross-Platform Development with Qt 6 and Modern C++ helps you understand why Qt is one of the favorite GUI frameworks adopted by industries worldwide, covering the essentials of programming GUI apps across a multitude of platforms using the standard C++17 and Qt 6 features.

Starting with the fundamentals of the Qt framework, including the features offered by Qt Creator, this practical guide will show you how to create classic user interfaces using Qt Widgets and touch-friendly user interfaces using Qt Quick. As you advance, you'll explore the Qt Creator IDE for developing applications for multiple desktops as well as for embedded and mobile platforms. You will also learn advanced concepts about signals and slots. Finally, the book takes you through debugging and testing your app with Qt Creator IDE.

By the end of this book, you'll be able to build cross-platform applications with a modern GUI along with the speed and power of native apps.

What you will learn

  • Write cross-platform code using the Qt framework to create interactive applications
  • Build a desktop application using Qt Widgets
  • Create a touch-friendly user interface with Qt Quick
  • Develop a mobile application using Qt and deploy it on different platforms
  • Get to grips with Model/View programming with Qt Widgets and Qt Quick
  • Discover Qt's graphics framework and add animations to your user interface
  • Write test cases using the Qt Test framework and debug code
  • Build a translation-aware application
  • Follow best practices in Qt to write high-performance code

Who this book is for

This book is for application developers who want to use C++ and Qt to create modern, responsive applications that can be deployed to multiple operating systems such as Microsoft Windows, Apple macOS, and Linux desktop platforms. Although no prior knowledge of Qt is expected, beginner-level knowledge of the C++ programming language and object-oriented programming system (OOPs) concepts will be helpful.

Table of Contents

  1. Cross-Platform Development with Qt 6 and Modern C++
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Reviews
  6. Section 1: The Basics
  7. Chapter 1: Introduction to Qt 6
    1. Technical requirements
    2. Introducing Qt
    3. Reasons for using Qt
    4. Downloading and installing Qt
    5. Downloading Qt
    6. Installing Qt on Windows
    7. Installing Qt on Linux
    8. Installing Qt on macOS
    9. Updating or removing Qt
    10. Building Qt 6 from source
    11. Installing Qt on Windows from source
    12. Installing Qt on Linux from source
    13. Installing Qt on macOS from source
    14. Summary
  8. Chapter 2: Introduction to Qt Creator
    1. Technical requirements
    2. Exploring the Qt Creator UI
    3. Building a simple Qt application
    4. Understanding advanced options
    5. Managing kits
    6. Qt Versions
    7. Environment
    8. Keyboard shortcuts
    9. Text Editor
    10. Splitting the coding window
    11. Build options
    12. Qt Assistant
    13. Summary
  9. Chapter 3: GUI Design Using Qt Widgets
    1. Technical requirements
    2. Introducing Qt widgets
    3. Creating a UI with Qt Designer
    4. Managing layouts
    5. QVBoxLayout
    6. QHBoxLayout
    7. QGridLayout
    8. Creating custom widgets
    9. Creating Qt Style Sheets and custom themes
    10. Using a QSS file
    11. Exploring custom styles
    12. Creating a custom style
    13. Using a custom style
    14. Using widgets, windows, and dialogs
    15. Summary
  10. Chapter 4: t Quick and QML
    1. Technical requirements
    2. Getting started with QML and Qt Quick
    3. Understanding the QML type system
    4. Understanding Qt Quick Controls
    5. Styling Qt Quick Controls
    6. Creating a simple Qt Quick application
    7. Designing a UI with Qt Quick Designer
    8. Positioners and layouts in QML
    9. Manual positioning
    10. Positioning with anchors
    11. Positioners
    12. Repeater
    13. Qt Quick Layouts
    14. Integrating QML with C++
    15. Embedding C++ objects into QML with context properties
    16. Registering a C++ class with the QML engine
    17. Creating a QML extension plugin
    18. Invoking QML methods inside a C++ class
    19. Exposing a QML object pointer to C++
    20. Integrating QML with JS
    21. Importing a directory in QML
    22. Handling mouse and touch events
    23. MouseArea
    24. MultiPointTouchArea
    25. TapHandler
    26. SwipeView
    27. Summary
  11. Section 2: Cross-Platform Development
  12. Chapter 5: Cross-Platform Development
    1. Technical requirements
    2. Understanding cross-platform development
    3. Understanding compilers
    4. Adding custom compilers
    5. Building with qmake
    6. Qt Project (.pro) files
    7. Understanding differences between .pro and .pri files
    8. Understanding build settings
    9. Platform-specific settings
    10. Using Qt with Microsoft Visual Studio
    11. Running a Qt application on Linux
    12. Running a Qt application on macOS and iOS
    13. Configuring Qt Creator for iOS
    14. Configuring Qt Creator for Android
    15. Other Qt-supported platforms
    16. Porting from Qt 5 into Qt 6
    17. Summary
  13. Section 3: Advanced Programming, Debugging, and Deployment
  14. Chapter 6: Signals and Slots
    1. Technical requirements
    2. Understanding Qt signals and slots
    3. Understanding syntax
    4. Declaring signals and slots
    5. Connecting the signal to the slot
    6. Connecting a single signal to multiple slots
    7. Connecting multiple signals to a single slot
    8. Connecting a signal to another signal
    9. The working mechanism of Qt signals and slots
    10. Qt's meta-object system
    11. MOC generated code
    12. Getting to know Qt's property system
    13. Reading and writing properties with the Meta-Object System
    14. Using signals and slots in Qt Designer
    15. Understanding signals and the handler event system in QML
    16. Adding a signal in QML
    17. Connecting a signal to a function
    18. Connecting a signal to a signal
    19. Defining property attributes and understanding property binding
    20. Integrating signals and slots between C++ and QML
    21. Understanding events and the event loop
    22. Managing events with an event filter
    23. Drag and drop
    24. Drag and drop in Qt Widgets
    25. Drag and drop in QML
    26. Summary
  15. Chapter 7: Model View Programming
    1. Technical requirements
    2. Understanding the M/V architecture
    3. Model
    4. Delegate
    5. Views in Qt Widgets
    6. Creating a simple Qt Widgets application using the M/V pattern
    7. Understanding Models and Views in QML
    8. Views in Qt Quick
    9. Models in Qt Quick
    10. Using C++ Models with QML
    11. Creating a simple M/V application with Qt Quick
    12. Summary
  16. Chapter 8: Graphics and Animations
    1. Technical requirements
    2. Understanding Qt's graphics framework
    3. QPainter and 2D graphics
    4. Understanding the paint system
    5. Using the coordinate system
    6. Drawing and filling
    7. Drawing with QPainter
    8. Introducing the Graphics View framework
    9. Understanding the Qt OpenGL module
    10. Qt OpenGL and Qt Widgets
    11. Graphics in Qt Quick
    12. Qt OpenGL and Qt Quick
    13. Custom Qt Quick items using QPainter
    14. Understanding the Qt Quick scene graph
    15. Qt Quick scene graph structure
    16. Rendering using a scene graph
    17. Using a scene graph with the Native Graphics
    18. 3D graphics with Qt Quick 3D
    19. Shader effects
    20. Using the Canvas QML type
    21. Understanding particle simulations
    22. Animation in Qt Widgets
    23. Animation and transitions in Qt Quick
    24. Controlling animations
    25. States, state machine, and transitions in Qt Quick
    26. The state machine in Qt Widgets
    27. Summary
  17. Chapter 9: Testing and Debugging
    1. Technical requirements
    2. Debugging in Qt
    3. Debuggers supported by Qt
    4. Debugging strategies
    5. Debugging a C++ application
    6. Debugging a Qt Quick application
    7. Testing in Qt
    8. Unit testing in Qt
    9. Integrating with Google's C++ testing framework
    10. Testing Qt Quick applications
    11. GUI testing tools
    12. The Linux Desktop Testing Project (LDTP)
    13. GammaRay
    14. Squish
    15. Summary
  18. Chapter 10: Deploying Qt Applications
    1. Technical requirements
    2. Understanding the need for deployment
    3. Choosing between static and dynamic libraries
    4. Deploying on desktop platforms
    5. Deploying on Windows
    6. Windows deployment tool
    7. Deploying on Linux
    8. Deploying on macOS
    9. Using the Qt Installer Framework
    10. Deploying on Android
    11. Other installation tools
    12. Summary
  19. Chapter 11: Internationalization
    1. Technical requirements
    2. Understanding internationalization and Qt Linguist
    3. Writing source code for translation
    4. Loading translations in a Qt application
    5. Switching languages dynamically
    6. Internationalization with Qt Widgets
    7. Adding dynamic translation to a Qt Widgets application
    8. Internationalization with Qt Quick
    9. Translating dynamically in a Qt Quick application
    10. Deploying translations
    11. Summary
  20. Chapter 12: Performance Considerations
    1. Technical requirements
    2. Understanding performance optimization
    3. Optimizing C++ code
    4. Using concurrency, parallelism, and multithreading
    5. Profiling a Qt Quick application using QML Profiler and Flame Graph
    6. Other Qt Creator analysis tools
    7. Optimizing graphical performance
    8. Creating benchmarks
    9. Different analysis tools and optimization strategies
    10. Memory profiling and analysis tools
    11. Optimizing during linking
    12. Building a Qt application faster
    13. Performance considerations for Qt Widgets
    14. Learning best practices of QML coding
    15. Summary
    16. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Leave a review - let other readers know what you think
3.15.218.254