Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Hands-On Embedded Programming with Qt
Hands-On Embedded Programming with Qt

Hands-On Embedded Programming with Qt: Develop high performance applications for embedded systems with C++ and Qt 5

eBook
$20.98 $29.99
Paperback
$43.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Embedded Programming with Qt

Setting Up the Environment

Did you ever buy something marked Some Assembly Required only to get it home and find out Some actually means several hours of work and that the tools you need aren't included? I feel guilty, because this chapter should be labeled Some Assembly Required, but at least I will help you to find all of the free tools you need.

In this chapter, we will look not only at getting the software tools, but also getting the hardware set up and working toward getting the best experience with the rest of this book. We will walk through the basic setup of the Qt toolchain, embedded compilers, and reference hardware.

The following topics will be covered in this chapter:

  • Creating our embedded environment
  • Preparing the host machine compiler
  • Building Qt for the target

Technical requirements

The following hardware will be needed in order to derive the most from this chapter and the rest of this book:

  • A target device (Raspberry Pi 3B+) with supporting hardware. See the Embedded Hardware and Firmware Setup section for more information.
  • A host development PC running Ubuntu 16.04 or higher. This can be running directly on a PC or in a VM with network access. Other Linux distributions may work, but this book is written for Ubuntu. (I am running Ubuntu 18.10 on dedicated hardware.) You will need the following access rights for your account on the host:
    • Administrative (or root) privileges for installing software on your development PC are needed.
    • A web browser (Chrome is recommended) is required.
    • Internet access is necessary.
    • The following tools should be configured and working on the host:
      • ssh
      • rsync
      • scp
      • tar
      • xz
      • bzip2
      • g++
      • patch
    • The Host...

Creating our embedded environment

As much as I would like to get right down to writing software, there are some hardware issues that need to be taken care of first. I chose to cover this first so that you have time to get everything together before you need to use it.

The Raspberry Pi 3B+ was chosen because of its low cost, high availability, and good community support. We will also be using the Raspberry Pi 7" touchscreen display and a Raspberry Pi Sense HAT. Additionally, you will want a USB keyboard, USB mouse (optional), power supply for the Raspberry Pi, and a 16 or 32 GB micro SD card.

You will also want a network connection between your Raspberry Pi and your development host. If possible, you will want the Raspberry Pi on the same network that your host uses for its network access; however, you may also choose to add an additional network interface to your...

Preparing the host machine

In this section, we will look at setting up the Linux host PC so that we can easily develop Qt applications.

Installing Qt

Qt comes in two basic licenses—Commercial and Open Source. We will be using the Open Source version.

Projects developed with the Open Source version of Qt must comply with the applicable GPL and LGPL licenses.

Qt can be download from https://qt.io/dowownload. Make sure to download the Linux version of the online installer for the Open Source version.

You might be wondering why we don't use the version of Qt already installed or installable from your Linux distribution. The answer is quite simple—to avoid confusion caused by different versions of Qt and its...

Building Qt for the Target

While Qt can sometimes be obtained for a specific target, the version we are running isn't available for the Raspberry Pi. Instead, we will look at how to build Qt from the sources. At first, it may seem like a daunting task, but it really is straightforward. Let's get to it:

  1. Before we start building Qt, we are going to make a backup copy of the source directory using tar. Open Command Prompt and cd to the installation directory for Qt 5.12.0. Next, tar up the Src directory, as follows:
[On Host] $ cd ~/Qt/5.12.0
[On Host] $ tar jcvf qt-5.12.0-src.tar.bz2 Src
Always keep the distribution sources untouched and don't build in the installed source directory. Use a copy of the directory instead. That way, should something happen, you won't have to re-download the sources.
  1. Now, extract the tarball into ~/raspi/Src and rename it ...

Running a quick test to ensure how the program works

If you've made it this far, your Qt for IoT Development environment and hardware should all be ready to go. Let's run a quick test to make sure this is the case. I've written a short test program to verify the basic setup of the Raspberry Pi itself. It can be found in the Git repository for this book. Download the single executable, C01_01-ItWorks, to ~/raspi. Transfer it to the device and then execute it. Then, follow these steps:

  1. On the host PC, enter the following command:
[On Host] $ scp ~/raspi/C01_01-ItWorks root@raspberrypi:/home/root
  1. Then, ssh into the Raspberry Pi and start it:
[On Target] $ /root/C01_01-ItWorks
  1. You should now see a picture with the words It Works! on the display. If not, verify your installation steps:

You can hit Ctrl+C in the ssh connection to terminate the program...

Summary

In this chapter, we learned how to set up a Raspberry Pi 3B+ for embedded Qt development. We also learned how to prepare a Linux host PC for cross compilation for the Raspberry Pi Target. We explored how to pull the parts of the root filesystem that are needed for development from the Target. Together, we also learned how to configure and build Qt from its source code and then push the updated root filesystem to the Target.

While we have only dealt with one particular Target, working with applications for other target systems is fairly straightforward. The differences will be in what initial target image you select, the cross compiling tool chain, and the way Qt is configured. Hopefully, by working through this chapter, you will be confident enough to be able to do it for any system you find.

In Chapter 2, Writing Your First Qt Application, we will write our first Qt program...

Questions

  1. Qt is available under what types of licenses? How are they different?
  2. What project allows you to custom build a Linux distribution for embedded use?
  3. How do you prepare to build Qt from its source code?
  4. What command can be used to synchronize directories across remote machines?
  5. What are two methods for sharing filesystems between remote machines?
  6. Is it okay to use the Qt version that's installed through Ubuntu? Why?
  7. What are the major steps that are needed to prepare Qt for working on a new device?
  8. How can you identify the device that's assigned to an SD card?

Further reading

You may also find the following Packt books to be useful regarding your learning experience:

  • Embedded Linux Development using Yocto Projects Second Edition, by Otavio Salvador and Daiane Angolini
  • Embedded Linux Development Using Yocto Project Cookbook  Second Edition, by Alex González
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Learn to create fluid, cross-platform applications for embedded devices
  • Achieve optimum performance in your applications with the QT Lite Project
  • Explore the implementation of Qt with IoT using QtMqtt, QtKNX, and QtWebSockets

Description

Qt is an open source toolkit suitable for cross-platform and embedded application development. This book uses inductive teaching to help you learn how to create applications for embedded and Internet of Things (IoT) devices with Qt 5. You’ll start by learning to develop your very first application with Qt. Next, you’ll build on the first application by understanding new concepts through hands-on projects and written text. Each project will introduce new features that will help you transform your basic first project into a connected IoT application running on embedded hardware. In addition to gaining practical experience in developing an embedded Qt project, you will also gain valuable insights into best practices for Qt development and explore advanced techniques for testing, debugging, and monitoring the performance of Qt applications. The examples and projects covered throughout the book can be run both locally and on an embedded platform. By the end of this book, you will have the skills you need to use Qt 5 to confidently develop modern embedded applications.

Who is this book for?

This book is for software and hardware professionals with experience in different domains who are seeking new career opportunities in embedded systems and IoT. Working knowledge of the C++ Linux command line will be useful to get the most out of this book.

What you will learn

  • Understand how to develop Qt applications using Qt Creator on Linux
  • Explore various Qt GUI technologies to build resourceful and interactive applications
  • Understand Qt's threading model to maintain a responsive UI
  • Get to grips with remote target load and debug using Qt Creator
  • Become adept at writing IoT code using Qt
  • Learn a variety of software best practices to ensure that your code is efficient

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 12, 2019
Length: 416 pages
Edition : 1st
Language : English
ISBN-13 : 9781789952063
Vendor :
Qt
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jul 12, 2019
Length: 416 pages
Edition : 1st
Language : English
ISBN-13 : 9781789952063
Vendor :
Qt
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 131.97
Hands-On Embedded Programming with Qt
$43.99
Hands-On Mobile and Embedded Development with Qt 5
$43.99
Qt5 C++ GUI Programming Cookbook
$43.99
Total $ 131.97 Stars icon
Banner background image

Table of Contents

19 Chapters
Section 1: Getting Started with Embedded Qt Chevron down icon Chevron up icon
Setting Up the Environment Chevron down icon Chevron up icon
Writing Your First Qt Application Chevron down icon Chevron up icon
Running Your First Application on the Target Chevron down icon Chevron up icon
Section 2: Working with Embedded Qt Chevron down icon Chevron up icon
Important Qt Concepts Chevron down icon Chevron up icon
Managing the Overall Workflow Chevron down icon Chevron up icon
Exploring GUI Technologies Chevron down icon Chevron up icon
Adding More Features Chevron down icon Chevron up icon
Section 3: Deep Dive into Embedded Qt Chevron down icon Chevron up icon
Qt in the Embedded World Chevron down icon Chevron up icon
Exploring the IoT with Qt Chevron down icon Chevron up icon
Using More Qt-Related Technologies Chevron down icon Chevron up icon
Section 4: Advanced Techniques and Best Practices Chevron down icon Chevron up icon
Debugging, Logging, and Monitoring Qt Applications Chevron down icon Chevron up icon
Responsive Application Programming - Threads Chevron down icon Chevron up icon
Qt Best Practices Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.8
(5 Ratings)
5 star 40%
4 star 40%
3 star 0%
2 star 0%
1 star 20%
Amazon Customer Sep 29, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nice book with comprehensive coverage and it is up to date.It helped me a lot. Good for understanding the concepts for embedded systems with c++ and Qt5.
Amazon Verified review Amazon
Sinclair Dec 21, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is the only book you will need to get started in embedded development using C++ and Qt. The author knows how to relate to reader in a very human way using his own real world experiences. The books starts out by explaining how to set up the development environment by providing all the details on where to download the tools and how to install the required software. Once the development environment has been set up, the author explains in great detail how to use the tools by going through a simple example using the cross compilation environment and building it for an embedded target, a raspberry pi microprocessor. As part of this simple example the author goes into great detail how to the the Qt cross compiler tool kit, which includes a full embedded development walk through from how to use the QtCreator IDE to selecting the target development kit, building the application, transferring it to the target microprocessor and running it.As you the read through the chapters you feel as through the author is sitting right next to you and providing the helpful instruction to make your software development successful. The book contains many great chapters on Qt concepts such as Signals and Slots, Modern software development, how to use Qt GUI technologies, Learning QML with QT Widgets as well as Unit Testing and Mock objects.All of this is to prepare the reader to work through a complete application that can run on the Raspberry Pi microprocessor. This project is called "The Big Project", this consists of building an application that will record the temperature each day on the target microprocessor and keep history of the temperatures. The author takes a standard project management approach to building the project. The project is broken up into phases or chapters. In each phase a set of requirements must be met before moving on to the next phase. During the development of the "Big Project", the reader learns about using databases with SQL , State Machine Design using the built-in support in Qt for state machines and D-Bus support for IPC. In the final phase, the author looks forward to the new technology of IoT (Internet of Things), a technology that we are now finding in our household appliances, media devices, lighting and thermostat controls etc. Here the author extends the "Big Project" to includes a WeatherFetcher. The WeatherFetcher is a web enabled application that fetches the current weather from a website. The books ends with some advanced topics, such as using Qt thread class, best practices for software development and Debugging, logging and monitoring.Through out the book, the author reinforces the knowledge learned through end of chapter assessments. These assist with ensuring the information from previous is understood before continuing with the next chapter. In summary, I can say that I am very impressed with the depth of knowledge that the Author, John Werner has with developing embedded solutions using Qt. This book is written in an insightful way that makes it easy for the beginning reader to understand as well experienced embedded developer. I highly recommend this book if you are developing Qt applications for embedded systems.
Amazon Verified review Amazon
Gabriel Nov 02, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I purchased this book with the primary goal of quickly understanding how Qt could be leveraged to develop embedded applications, and it fulfilled my needs.I should note that I skipped all the exercises/practical parts and remained hands-off so that I could finish reading the book over a weekend, so I cannot comment on those aspects which might be the most important to some readers.
Amazon Verified review Amazon
TB May 27, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I bought this book from the publisher's website (Packt) about two weeks ago, and have been working through it for several hours per day on most days. It's badly out of date, as both Qt and the Yocto build used by the author are very outdated. So it's a challenge to get things working as written in the book, and despite the author's not wanting to use Raspbian, I actually found it much easier to get going with in terms of cross-compiling Qt applications. Perhaps more concerning though is that the book, when written, doesn't appear to have had a very thorough review by a Technical Editor. I've been the Technical Editor on a leading book on the Raspberry Pi, and can say with certainty that this book really didn't much of a going-over by whoever was the TE. It's got quite a number of blatant errors in the book for instance, and in many cases the examples given are simply incorrect. I'm just over halfway through the book and have found quite a number of errors. I've searched the publisher's website for an errata section, but there is none to be found--and no visible way to report such problems.Also, the github repo for the book has code that differs significantly from the examples listed in the book. This could certainly have been updated since the writing of the book though, so that in-and-of-itself is not an indication that things went awry. But the reader should be cautioned that they will absolutely need to clone the repo and review the code as you work through the book--because otherwise many things really just don't work correctly. Also keep in mind that there are several online tutorials for building a cross-compilation toolchain for Raspbian on the RPi...but those are only similar to a point, given that the author has chosen to use Yocto for the OS on the device. However they are great references for when things don't go exactly right with the procedure listed in this book, so don't be afraid to check them out if you're having problems getting the code to build.So overall I gave the book 4-stars, but in reality it's probably a 3.5-star publication. It's somewhat sad too, because the book has tremendous potential. It simply needs a good updating and, more importantly, a VERY thorough review by a Technical Editor with an eye for detail, and the time to run each and every code example in the book.
Amazon Verified review Amazon
David Sep 08, 2021
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
Seems like an awesome book but I can't get the code running as it relies on a missing download from an external company. As I bought this book as a learning tool, I quickly got frustrated because of this. The rest of the content does seem good if you can get that far
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.