May 2019
Intermediate to advanced
542 pages
13h 37m
English
A thread is an independent code execution context. By default, all of our code runs in a single thread, so we refer to it as a single-threaded application. Using the QtCore.QThread class, we can create new threads and move portions of our code to them, making it a multithreaded application.
You can use the QThread object as follows:
self.searcher_thread = qtc.QThread() self.ss.moveToThread(self.searcher_thread) self.ss.finished.connect(self.searcher_thread.quit) self.searcher_thread.start()
We start by creating a QThread object, and then use the SlowSearcher.moveToThread() method to move our SlowSearcher object to the new thread. moveToThread() is a QObject method inherited by any class that subclasses QObject.
Next, we connect ...
Read now
Unlock full access