views:

575

answers:

3

Hi,

I use qt a lot. I want to know something: how many threads does Qt create do to things in the background? like handling signals and slots..

Also, any GUI toolkit creates Event threads too (i seem to remember java does). Does Qt create one too?

EDIT: when I say "how many threads", I really mean which threads

Thanks,
jrh

+3  A: 

Qt's signals and slots are not implemented using multiple threads, they're just a way of handling the bookkeeping for event distribution.

One thing you can do is run your program, count the threads using whatever OS facility you like (such as Task Manager on Windows), and see whether that matches what you expect. I wouldn't expect Qt to create any additional threads unless you ask it to.

Greg Hewgill
okay, i verified this by writing a program... thanks
Here Be Wolves
+2  A: 

As Greg mentioned, signals and slots do not use threads. Generally, Qt will never create threads to do things in the background, Except:

  • The Network code, which can create a thread to do DNS lookups.

  • The QThreadPool will create N + 1 threads when you initialise it (or use it for the first time), where N is the number of CPU cores.

Cheers,

Thomi
+1  A: 

QFileSystemModel uses a separate thread to populate itself so it will not cause the main thread to hang as the file system is being querie.

TimW