Application Development with Qt Creator
eBook - ePub

Application Development with Qt Creator

Build cross-platform applications and GUIs using Qt 5 and C++, 3rd Edition

  1. 426 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Application Development with Qt Creator

Build cross-platform applications and GUIs using Qt 5 and C++, 3rd Edition

About this book

Explore Qt Creator, Qt Quick, and QML to design and develop applications that work on desktop, mobile, embedded, and IoT platforms

Key Features

  • Build a solid foundation in Qt by learning about its core classes, multithreading, File I/O, and networking
  • Learn GUI programming and build custom interfaces using Qt Widgets, Qt Designer, and QML
  • Use the latest features of C++17 for improving the performance of your Qt applications

Book Description

Qt is a powerful development framework that serves as a complete toolset for building cross-platform applications, helping you reduce development time and improve productivity. Completely revised and updated to cover C++17 and the latest developments in Qt 5.12, this comprehensive guide is the third edition of Application Development with Qt Creator.

You'll start by designing a user interface using Qt Designer and learn how to instantiate custom messages, forms, and dialogues. You'll then understand Qt's support for multithreading, a key tool for making applications responsive, and the use of Qt's Model-View-Controller (MVC) to display data and content. As you advance, you'll learn to draw images on screen using Graphics View Framework and create custom widgets that interoperate with Qt Widgets. This Qt programming book takes you through Qt Creator's latest features, such as Qt Quick Controls 2, enhanced CMake support, a new graphical editor for SCXML, and a model editor. You'll even work with multimedia and sensors using Qt Quick, and finally develop applications for mobile, IoT, and embedded devices using Qt Creator.

By the end of this Qt book, you'll be able to create your own cross-platform applications from scratch using Qt Creator and the C++ programming language.

What you will learn

  • Create programs from scratch using the Qt framework and C++ language
  • Compile and debug your Qt Quick and C++ applications using Qt Creator
  • Implement map view with your Qt application and display device location on the map
  • Understand how to call Android and iOS native functions from Qt C++ code
  • Localize your application with Qt Linguist
  • Explore various Qt Quick components that provide access to audio and video playbacks
  • Develop GUI applications using both Qt and Qt Quick

Who this book is for

If you are a beginner looking to harness the power of Qt and the Qt Creator framework for cross-platform development, this book is for you. Although no prior knowledge of Qt and Qt Creator is required, basic knowledge of C++ programming is assumed.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Application Development with Qt Creator by Lee Zhi Eng,Ray Rischpater in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C++. We have over one million books available in our catalogue for you to explore.

Information

Section 1: The Basics

In the first section of this book, we will look into the basics of Qt Creator and how to build and design applications with it, and also delve into the foundations of Qt. These form the prerequisites for our advanced topics ahead.
This section comprises the following chapters:
  • Chapter 1, Getting Started with Qt Creator
  • Chapter 2, Building Applications with Qt Creator
  • Chapter 3, Designing Your Application with Qt Designer
  • Chapter 4, Qt Foundations
  • Chapter 5, Developing Applications with Qt Widgets

Getting Started with Qt Creator

Qt Creator is an integrated software development environment that supports both traditional C++ application development and development using the Qt project's libraries (collectively called Qt and pronounced as cute).
Qt is available under a commercial license as well as under GPL v3 and LGPL v2. Its development dates all the way back to 1991. For the first 10 years of its life, it was a cross-platform toolkit for Windows and X11; by 2001, support for macOS X had been added.
In this chapter, we will take a look at everything you need to get started, as follows:
  • Where to download Qt Creator for Linux, macOS X, and Windows
  • New features in the latest version of Qt
  • How to ensure that your basic configuration is running
  • A quick look at a simple Qt Widgets application as well as a Qt Quick application

Technical requirements

The technical requirements for this chapter include Qt 5.12.3 MinGW 64-bit, Qt Creator 4.9.0, and Windows 10.
The code for this chapter can be found at https://github.com/PacktPublishing/Application-Development-with-Qt-Creator-Third-Edition/tree/master/Chapter01.

Downloading Qt and Qt Creator

Qt, the cross-platform toolkit behind Qt Creator, has had a long and illustrious history. Presently a project of The Qt Company, it has its own URL: http://www.qt.io. It also has both commercial and non-commercial licenses. To get started with the non-commercial version for free, go to http://www.qt.io/download-qt-installer. You should see something similar to the following screenshot:
One of the most popular platforms for application development with Qt is Linux. On many Linux variants—notably Ubuntu, my personal favorite – you can get Qt Creator using the package manager. On my Ubuntu box, Qt Creator is just a sudo apt-get install qtcreator command away. You'll get a version of Qt that matches your flavor of Linux, although it might not be the latest and greatest build from The Qt Company. If you need to install the latest official version of Qt, it's recommended to download it from the preceding link.
Some downloads include the C++ compiler and the linker that you need. By following the link and downloading Qt, you should now have Qt, Qt Creator, and the MinGW toolkit for developing software on Windows. If you're developing on Linux or Mac, the process will be similar, although it won't include MinGW in your development. On Windows, there's a variant that includes the MinGW toolchain, so you have everything you need to build applications.
However, you can also download Qt Creator for Windows, which uses the Microsoft Visual Studio compiler. So, if you prefer using Visual Studio for your compilation and Qt Creator as your IDE, this is also an option. On macOS X, you'll need to have Xcode and the command-line development tools installed first; you can download Xcode from the macOS X App Store and then use Xcode to download the command-line development tools.
Once the installer downloads, run it in the usual way and it'll launch an installation wizard for your platform. Depending on whether you're running the online installer or the offline installer, installation for the latter should typically take anywhere from 3 to 4 minutes; however, it may take several hours if you're running the online installer. This is because when you run the installation process, the online installer downloads every single tool and library file from the Qt server uncompressed. On the other hand, the offline installer contains all the tools and libraries in a heavily compressed format packed within the installer itself, which is why the installation process is relatively quicker and simpler, but has a larger-sized installer compared to the online installer.
Other than that, you'll want to have plenty of disk space. Qt Creator doesn't consume that much disk space, but software development does; you'll need at least 500 MB of empty space for the tools and libraries, and you'll need to budget a few free gigabytes on your main drive for your source code, intermediate object files, debugging symbols, and, of course, your compiled application. (It is especially important to plan for this if you're running Qt Creator on a virtual machine; make sure that the virtual hard drive for your virtual machine image has plenty of disk space.)
You should also ensure that your development box has plenty of RAM; the more, the better. Qt Creator runs happily on 2 GB of RAM, but the compiler and linker used by Qt Creator can run a lot faster if they have more RAM available.

New features in Qt

Qt developers are constantly adding new features to Qt while fixing critical bugs that affect its users. This means that we can expect new features in every update of Qt, especially a major release. At the time of writing this chapter, the latest stable version of Qt is 5.12.3, which means it's the third minor update for its major version, 5.12.
Some of the important changes to Qt since the second edition of this book are as follows:
  • Qt WebView (WebKit) has been deprecated and replaced by Qt WebEngine (Chromium).
  • MinGW 64-bit compiler is now included in Qt's Windows installer.
  • Many features have been added to the mobile platforms, including support for in-app purchasing.
  • Qt Script, Qt Quick Control 1, and Qt Canvas 3D have been deprecated.
  • Added support for new platforms, such as tvOS and watchOS.
  • Previously commercial-only features such as Qt Charts, Qt Data Visualization, Qt Virtual Keyboard, Qt Purchasing, and Qt Quick 2D Renderer are now free.
  • Added support for embedded platforms.
  • Added Qt Automotive Suite.
  • Qt binding for Python has been added (using the PySide 2 module).
  • New signal and slot connection syntax – you can now directly connect a signal to a C++11 lambda function.
  • Added support for JSON format.
  • Added Qt 3D Studio.
  • Added SCXML and state machine tooling in Qt Creator.
...and there are many more besides!
To learn more about the new features and changes in the latest Qt release, please check out the official introduction for Qt 5 at https://doc.qt.io/qt-5/qt5-intro.html, or head over to the wiki page at https://wiki.qt.io/Main.

Finding your way around Qt Creator

The following screenshot shows what you will see when you launch Qt Creator for the first time. Let's take a closer look at each portion of the screen:
The main window, which currently shows the buttons for New Project and Open Proje...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. About Packt
  4. Contributors
  5. Preface
  6. Section 1: The Basics
  7. Getting Started with Qt Creator
  8. Building Applications with Qt Creator
  9. Designing Your Application with Qt Designer
  10. Qt Foundations
  11. Developing Applications with Qt Widgets
  12. Section 2: Advanced Features
  13. Drawing with Qt
  14. Doing More with Qt Quick
  15. Implementing Multimedia with Qt Quick
  16. Sensors and Qt Quick
  17. Section 3: Practical Matters
  18. Localizing Your Application with Qt Linguist
  19. Optimizing Performance with Qt Creator
  20. Developing Mobile Applications with Qt Creator
  21. Embedded and IoT Development with Qt Creator
  22. Qt Tips and Tricks
  23. Other Books You May Enjoy