Thread handling
As shown in the preceding click handlers, the multi-threaded aspects of a complex application are handled by the signal-slot design in Qt. Code executed in a slot will be running on the correct thread to do graphical updates. Additionally, any data passed as part of the signal definition can be accessed in a thread-safe manner. We'll make use of this property to handle our background email notifications.
To set this up, we create a new custom signal. This is made possible by the qtmoc tool, which comes with therecipe/qt bindings. We'll update our mainUI struct definition to inherit from core.QObject (this is a requirement) and then define an anonymous function with the signal tag, which defines the name of the signal:
core.QObject ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access