I would like to know if the function do_something() is treated as a new thread, when I click on my_button.
connect(my_button, SIGNAL(clicked), this, SLOT(do_something));
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The typical signal/slot behavior is determined based on the connection type. When unspecified, it defaults to
Qt::AutoConnectionand will use the receiver’s thread if a direct connection can’t be made.From the docs:
You can change the connection type at connect time to alter the behavior:
Since you’re talking about a button that’s emitting the signal, the default connection type of
Qt::AutoConnectionimplies that a direct connection is made and that thedo_somethingslot will be executed immediately as if it had been called directly at the point the button was clicked.