Mastering Qt 5

Book description

An In-depth guide updated with the latest version of Qt 5.11 including new features such as Quick Controls and Qt Gamepad

Key Features

  • Unleash the power of Qt 5.11 with C++
  • Build applications using Qt Widgets (C++) or Qt Quick (QML)
  • Create cross-platform applications for mobile and desktop platforms with Qt 5

Book Description

Qt 5.11 is an app development framework that provides a great user experience and develops full capability applications with Qt Widgets, QML, and even Qt 3D. Whether you're building GUI prototypes or fully-fledged cross-platform GUI applications with a native look and feel, Mastering Qt 5 is your fastest, easiest, and most powerful solution. This book addresses various challenges and teaches you to successfully develop cross-platform applications using the Qt framework, with the help of well-organized projects.

Working through this book, you will gain a better understanding of the Qt framework, as well as the tools required to resolve serious issues, such as linking, debugging, and multithreading. You'll start off your journey by discovering the new Qt 5.11 features, soon followed by exploring different platforms and learning to tame them. In addition to this, you'll interact with a gamepad using Qt Gamepad. Each chapter is a logical step for you to complete in order to master Qt.

By the end of this book, you'll have created an application that has been tested and is ready to be shipped.

What you will learn

  • Create stunning UIs with Qt Widgets and Qt Quick 2
  • Develop powerful, cross-platform applications with the Qt framework
  • Design GUIs with the Qt Designer and build a library in it for UI previews
  • Handle user interaction with the Qt signal or slot mechanism in C++
  • Prepare a cross-platform project to host a third-party library
  • Use the Qt Animation framework to display stunning effects
  • Deploy mobile apps with Qt and embedded platforms
  • Interact with a gamepad using Qt Gamepad

Who this book is for

Mastering Qt 5 is for developers and programmers who want to build GUI-based applications. C++ knowledge is necessary, and knowing QT basics will help you get the most out of this book.

Publisher resources

Download Example Code

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Qt 5 Second Edition
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
  5. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  6. 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. Conventions used
    4. Get in touch
      1. Reviews
  7. Get Your Qt Feet Wet
    1. Qt project basic structure
    2. MainWindow structure
    3. Qt Designer interface
    4. Signals and slots
    5. Custom QWidget
    6. Adding a task
    7. Using a QDialog
    8. Distributing code responsibility
    9. Emitting a custom signal using lambdas
    10. Simplifying with the auto type and a range-based for loop
    11. Summary
  8. Discovering qmake Secrets
    1. Designing a cross-platform project
      1. Adding the Windows implementation
      2. Adding the Linux implementation
      3. Adding the macOS implementation
    2. Transforming SysInfo into a singleton
    3. Exploring Qt Charts
    4. CpuWidget using QCharts
    5. Memory using Qcharts
    6. The .pro file in depth
    7. Under the hood of qmake
    8. Beneath Q_OBJECT and signals/slots
    9. Summary
  9. Dividing Your Project and Ruling Your Code
    1. Designing a maintainable project
    2. Defining data classes
    3. Storing your data in a database
    4. Protecting your code with a smart pointer
    5. Implementing the model
    6. Summary
  10. Conquering the Desktop UI
    1. Creating a GUI linked to a core shared library
    2. Listing your albums with AlbumListWidget
    3. Creating ThumbnailProxyModel
    4. Displaying the selected album with AlbumWidget
    5. Enhancing thumbnails with PictureDelegate
    6. Displaying a picture with PictureWidget
    7. Composing your Gallery app
    8. Summary
  11. Dominating the Mobile UI
    1. Starting with Qt Quick and QML
    2. Checking your development environment
    3. Creating a Qt Quick project
    4. Preparing your Qt Quick gallery entry point
    5. Displaying albums with ListView
    6. Theming the application with a QML singleton
    7. Loading a database on mobile devices
    8. Creating a new album from a custom InputDialog
    9. Loading images with an ImageProvider
    10. Displaying thumbnails in GridView
    11. Swiping through full resolution images
    12. Summary
  12. Even Qt Deserves a Slice of Raspberry Pi
    1. Discovering Qt3D
    2. Configuring Qt for your Raspberry Pi
    3. Creating an entry point for your Qt3D code
    4. Setting up the scene
    5. Assembling your Qt3D entities
    6. Preparing the board game
    7. Crafting entities from the factory
    8. Building a snake engine in JavaScript
    9. Varying the HUD with QML states
    10. Profiling your QML application
    11. Summary
  13. Third-Party Libraries without a Headache
    1. Creating your Qt Designer plugin
    2. Configuring the project for Windows
    3. Configuring the project for Linux
    4. Configuring the project for Mac
    5. Implementing your OpenCV filters
    6. Designing the UI with FilterWidget
    7. Exposing your plugin to Qt Designer
    8. Using your Qt Designer plugin
    9. Building the image-filter application
    10. Summary
  14. Animations - Its Alive, Alive!
    1. Creating an SDK using the Qt Plugin system
    2. Creating your plugins
    3. Loading your plugins dynamically
    4. Using the plugins inside the application
    5. Discovering the Animation Framework
    6. Making your thumbnails jump
    7. Fading in the picture
    8. Flashing the thumbnail in a sequence
    9. Summary
  15. Keeping Your Sanity with Multithreading
    1. Discovering QThread
    2. Flying over Qt multithreading technologies
    3. Architecting the Mandelbrot project
    4. Defining a Job class with QRunnable
    5. Using QThreadPool in MandelbrotCalculator
    6. Displaying the fractal with MandelbrotWidget
    7. Summary
  16. Need IPC? Get Your Minions to Work
    1. Inter-process communication techniques
    2. Architecturing an IPC project
    3. Laying down the foundations with an SDK
    4. Working with QDataStream and QTcpSocket
    5. Interacting with sockets in the worker
    6. Interacting with sockets from the application
    7. Building your own QTcpServer
    8. Summary
  17. Having Fun with Multimedia and Serialization
    1. Architecting the drum machine project
    2. Creating a drum track
    3. Making your objects serializable with QVariant
    4. Serializing objects in JSON format
    5. Serializing objects in XML format
    6. Serializing objects in binary format
    7. Playing low-latency sounds with QSoundEffect
    8. Triggering a QButton with your keyboard
    9. Bringing PlaybackWorker to life
    10. Accepting mouse drag-and-drop events
    11. Summary
  18. You Shall (Not) Pass with QTest
    1. Discovering Qt Test
    2. Executing your tests
    3. Writing factorized tests with datasets
    4. Benchmarking your code
    5. Testing your GUI
    6. Spying on your application with QSignalSpy
    7. Summary
  19. All Packed and Ready to Deploy
    1. Packaging your application
    2. Packaging for Windows
    3. Packaging for Linux with a distribution package
    4. Packaging for Linux with AppImage
    5. Packaging for OS X
    6. Packaging for Android
    7. Packaging for iOS
    8. Summary
  20. Qt Hat Tips and Tricks
    1. Managing your workspace with sessions
    2. Searching with the Locator
    3. Increasing the compilation speed
    4. Examining memory with Qt Creator
    5. Generating random numbers
    6. Silencing unused variable warnings
    7. Logging custom objects to QDebug
    8. Improving log messages
    9. Saving your logs to a file
    10. Generating a command-line interface
    11. Sending and receiving HTTP data
    12. Playing with Qt Gamepad
    13. Styling QML with Qt Quick Controls 2
    14. Summary
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Mastering Qt 5
  • Author(s): Guillaume Lazar, Robin Penea
  • Release date: August 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788995399