If I connect the same signal with the same slot twice, would this cause a bug? e.g the slot get called twice when the signal is emitted?
Share
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.
Short answer: Your slot would be called twice.
Whether this causes bugs or is the desired behaviour depends on your application of course.
In most cases it is probably not wanted, so to prevent this you can either track your connections, use disconnect first or if you are using at least Qt 4.6 there is a new connection type
Qt::UniqueConnectionwhich prevents duplicate connections automatically and otherwise behaves likeQt::AutoConnection, see connection types and a blog post about the new unique type.