Book Image

QT5 Blueprints

By : Symeon Huang
Book Image

QT5 Blueprints

By: Symeon Huang

Overview of this book

Table of Contents (17 chapters)
Qt 5 Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing multithreaded applications


I bet multithread or threading isn't unfamiliar to you. Using other threads saves the GUI application from freezing. If the application runs on a single thread, it'll get stuck if there it's a synchronous time-consuming operation. Multiple threads make application running much smoother. Although most of the Qt Network APIs are nonblocking, it is not that difficult to practice on it.

Qt provides a QThread class to implement threading on all supported platforms. In other words, we don't need to write platform-specific code utilizing POSIX Threads or a Win32 API. Instead, QThread provides a platform-independent way to manage threads. A QThread object manages a thread within the program, which begins executing in run() and ends when calling quit() or exit().

For some historical reason, it's still possible to subclass QThread and put the blocking or time-consuming code in the reimplemented run() function. However, it's considered an incorrect practice and is not...