Book Image

Hands-On Mobile and Embedded Development with Qt 5

By : Lorn Potter
Book Image

Hands-On Mobile and Embedded Development with Qt 5

By: Lorn Potter

Overview of this book

Qt is a world-class framework, helping you to develop rich graphical user interfaces (GUIs) and multi-platform applications that run on all major desktop platforms and most mobile or embedded platforms. The framework helps you connect the dots across platforms and between online and physical experience. This book will help you leverage the fully-featured Qt framework and its modular cross-platform library classes and intuitive APIs to develop applications for mobile, IoT, and industrial embedded systems. Considerations such as screen size, device orientation changes, and small memory will be discussed. We will focus on various core aspects of embedded and mobile systems, such as connectivity, networking, and sensors; there is no IoT without sensors. You will learn how to quickly design a flexible, fast, and responsive UI that looks great. Going further, you will implement different elements in a matter of minutes and synchronize the UI elements with the 3D assets with high precision. You will learn how to create high-performance embedded systems with 3D/2D user interfaces, and deploy and test on your target hardware. The book will explore several new features, including Qt for WebAssembly. At the end of this book, you will learn about creating a full software stack for embedded Linux systems using Yocto and Boot to Qt for Device Creation.
Table of Contents (23 chapters)
Title Page
Dedication
About Packt
Foreword
Contributors
Preface
Index

High level – request, reply, and access


Networking in Qt is quite feature-rich. Networking in Qt Quick is more behind the scenes than in your face. In Qt Modeling Language (QML), you can download remote components and use them in your application, but any other arbitrary download or network functionality you will have to bake yourself in the C++ backend or use JavaScript.

Even though QNetworkRequest, QNetworkReply, and QNetworkAccessManager are all used to make network requests, let's split them up and see how to use them.

QNetworkRequest

QNetworkRequest is a part of the access functionality. It constructs a request, which can be one of the following verbs:

  • GET: get(...)
  • POST: post(...)
  • PUT: put(...)
  • DELETE: deleteResource(...)
  • HEAD: head(...)

You can also send custom verbs using sendCustomRequest, which takes the custom verb as a QByteArray argument.

Headers can be set as known headers using setHeader and can be one of the following:

  • ContentDispositionHeader
  • ContentTypeHeader
  • ContentLengthHeader
  • LocationHeader...