C ++ Qt - When a slot is called, is a function called a new thread?

I would like to know if a function is treated do_something()as a new thread when I click my_button.

connect(my_button, SIGNAL(clicked), this, SLOT(do_something));
+5
source share
1 answer

Typical signal / slot behavior is determined based on the type of connection . If a value is not specified, it is equal by default Qt::AutoConnectionand will use the recipient stream if a direct connection cannot be made.

From the docs:

The slot is called when control returns to the event loop of the receiver stream. The slot runs in the receiver stream.

You can change the type of connection during the connection to change the behavior:

connect(my_button, SIGNAL(clicked), this, SLOT(do_something),
    Qt::QueuedConnection); // always queue

, , Qt::AutoConnection , , do_something , .

+8

All Articles