Thread-Support in Qt Modules¶
Threads and the SQL Module¶
A database connection must only be used from within the thread that created it. Moving a connection into another thread can be done with QSqlDatabase::moveToThread().
In addition, the third party libraries used by the QSqlDrivers can impose further restrictions on using the SQL Module in a multithreaded program. Consult the manual of your database client for more information
Painting in Threads¶
QPainter can be used in a thread to paint onto QImage, QPrinter, QPicture, and (for most platforms) QPixmap paint devices. Painting onto QWidgets is not supported. On macOS the automatic progress dialog will not be displayed if you are printing from outside the GUI thread.
Any number of threads can paint at any given time, however only one thread at a time can paint on a given paint device. In other words, two threads can paint at the same time if each paints onto separate QImages, but the two threads cannot paint onto the same QImage at the same time.
Threads and Rich Text Processing¶
The QTextDocument, QTextCursor, and all related classes are reentrant.
Note that a QTextDocument instance created in the GUI thread may contain QPixmap image resources. Use QTextDocument::clone() to create a copy of the document, and pass the copy to another thread for further processing (such as printing).
Threads and the SVG Module¶
The QSvgGenerator and QSvgRenderer classes in the QtSvg module are reentrant.