Will the call be called several times if I connect the same slots several times?

If I connect the same signal with one slot twice, can this cause an error? for example, is a slot called up twice when a signal is emitted?

+4
source share
1 answer

Short answer: your slot will be called twice.

Whether this is the cause of errors or is the desired behavior depends on your application, of course.

In most cases, this is probably not necessary, therefore, to prevent this, you can monitor your connections, first disconnect the connection, or if you use at least Qt 4.6, there is a new connection type Qt::UniqueConnection that prevents duplicate connections automatically and otherwise it behaves like Qt::AutoConnection , see connection types and blog post for a new unique type .

+7
source

Source: https://habr.com/ru/post/1443590/


All Articles