Next, we want to explore some other methods so that we can use threads in Qt 5 applications. Qt 5 provides a class called QThread, which gives you more control of how you create and execute a thread. A QThread object begins to execute its event loops in a thread by calling the run() function. In this example, we will learn how to make QObject work together asynchronously through QThread.
QObject and QThread
How to do it...
Let's get started by preforming the following steps:
- Create a new Qt Widgets Application project. Then, go to File | New File or Project... and create a C++ Class:
- After that, name the new class MyWorker and make it inherit from the QObject class. Don't forget to include the QObject class...