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
€17.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

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 : 9781789953800
Vendor :
Qt
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.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
€189.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
€264.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 98.97
Hands-On Embedded Programming with Qt
€32.99
Hands-On Mobile and Embedded Development with Qt 5
€32.99
Qt5 C++ GUI Programming Cookbook
€32.99
Total 98.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

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.