Mastering Qt 5

Book description

Master application development by writing succinct, robust, and reusable code with Qt 5

About This Book

  • Unleash the power of Qt 5 with C++14

  • Integrate useful third-party libraries such as OpenCV

  • Package and deploy your application on multiple platforms

  • Who This Book Is For

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

    What You Will Learn

  • Create stunning UIs with Qt Widget and Qt Quick

  • Develop powerful, cross-platform applications with the Qt framework

  • Design GUIs with the Qt Designer and build a library in it for UI preview

  • Handle user interaction with the Qt signal/slot mechanism in C++

  • Prepare a cross-platform project to host a third-party library

  • Build a Qt application using the OpenCV API

  • Use the Qt Animation framework to display stunning effects

  • Deploy mobile apps with Qt and embedded platforms

  • In Detail

    Qt 5.7 is an application development framework that provides a great user experience and develops full-capability applications with Qt Widgets, QML, and even Qt 3D.

    This book will address challenges in successfully developing cross-platform applications with the Qt framework. Cross-platform development needs a well-organized project. Using this book, you will have a better understanding of the Qt framework and the tools to resolve serious issues such as linking, debugging, and multithreading. Your journey will start with the new Qt 5 features. Then you will explore different platforms and learn to tame them. Every chapter along the way is a logical step that you must take to master Qt. The journey will end in an application that has been tested and is ready to be shipped.

    Style and approach

    This is an easy-to-follow yet comprehensive guide to building applications in Qt. Each chapter covers increasingly advanced topics, with subjects grouped according to their complexity as well as their usefulness. Packed with practical examples and explanations, Mastering Qt contains everything you need to take your applications to the next level.

    Publisher resources

    Download Example Code

    Table of contents

    1. Mastering Qt 5
      1. Mastering Qt 5
      2. Credits
      3. About the Authors
      4. About the Reviewer
        1. Why subscribe?
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      7. 1. Get Your Qt Feet Wet
        1. Creating a project
        2. MainWindow structure
        3. Qt Designer
        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. 2. Discovering QMake Secrets
        1. Designing a cross-platform project
          1. Adding the Windows implementation
          2. Adding the Linux implementation
          3. Adding the Mac OS 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. 3. 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. 4. Conquering the Desktop UI
        1. Creating a GUI linked to a core shared library
        2. Listing your albums with AlbumListWidget
        3. Creating a 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. 5. 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
        8. Creating a new album from a custom InputDialog
        9. Loading images with an ImageProvider
        10. Displaying thumbnails in a GridView
        11. Swiping through full resolution pictures
        12. Summary
      12. 6. 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. 7. 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. 8. Animations - It's Alive, Alive!
        1. Preparing an SDK
        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 the picture in
        8. Flashing the thumbnail in a sequence
        9. Summary
      15. 9. 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. 10. Need IPC? Get Your Minions to Work
        1. Architecturing an IPC project
        2. Laying down the foundations with an SDK
        3. Working with QDataStream and QTcpSocket
        4. Interacting with sockets in the worker
        5. Interacting with sockets from the application
        6. Building your own QTcpServer
        7. Summary
      17. 11. Having Fun with 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. 12. 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. 13. 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 Mac OS X
        6. Packaging for Android
        7. Packaging for iOS
        8. Summary
      20. 14. Qt Hat Tips and Tricks
        1. Managing your workspace with sessions
        2. Searching with the Locator
        3. Increasing the compilation speed
        4. Examining the 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. Summary

    Product information

    • Title: Mastering Qt 5
    • Author(s): Guillaume Lazar, Robin Penea
    • Release date: December 2016
    • Publisher(s): Packt Publishing
    • ISBN: 9781786467126