I would like to know if a function is treated do_something()as a new thread when I click my_button.
do_something()
my_button
connect(my_button, SIGNAL(clicked), this, SLOT(do_something));
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.
Qt::AutoConnection
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 , .
do_something