[Development] How many threads created for QML Application by default ?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Fri Aug 6 14:11:38 CEST 2021


Hi,

On 06/08/2021 13:43, Vinoth Rajendran wrote:
> I have seen in qt documentation that a single thread(GUI thread) is 
> created by a program at start-up.
> But I could see a bunch of threads in the main() function. Can someone 
> help me understand it ?
> 
> Please find the screenshots for reference,
> 
> threads.png 
> <https://ddgobkiprc33d.cloudfront.net/48ec7519-dd52-4d06-b63e-b70b0d576ffc.png>
> 
> Here i could see around 8 threads created

Qt may spawn additional threads internally. ~100% of the time, they're 
invisible to the developer, and used just by Qt for its own purposes. In 
other words, the code you're going to write will run in the main thread 
and you'll never know about the other threads. Just ignore their existence.

QtQuick has one special thread of you should aware of, which is its 
rendering thread. If you plan to do custom drawing, in C++, using 
QtQuick APIs, then the docs will tell you about this rendering thread 
and how to avoid shooting yourself in the foot. But if you just use 
QtQuick from QML, or use C++ drawing bits that aren't related to QtQuick 
(like QImage, then again everything will be ran in the main/GUI thread.

Hope this helps,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.qt-project.org/pipermail/development/attachments/20210806/50c8329c/attachment.bin>


More information about the Development mailing list