{"id":375,"date":"2011-10-24T16:25:37","date_gmt":"2011-10-24T23:25:37","guid":{"rendered":"http:\/\/www.lothlorien.com\/kf6gpe\/?p=375"},"modified":"2011-10-25T09:28:35","modified_gmt":"2011-10-25T16:28:35","slug":"are-your-signals-not-disconnecting","status":"publish","type":"post","link":"https:\/\/www.lothlorien.com\/kf6gpe\/are-your-signals-not-disconnecting\/","title":{"rendered":"Are your Qt signals not disconnecting?"},"content":{"rendered":"<p>This was probably obvious to everyone except me&#8230;<br \/>\n<code>disconnect(object)<\/code><br \/>\nis <em>not<\/em> the same as<br \/>\n<code>disconnect(object, 0, 0, 0)<\/code><\/p>\n<p>This makes perfect sense when you look at the overloaded function definitions for <code>disconnect<\/code>, one of which reads:<br \/>\n<code>bool QObject::disconnect ( const QObject * receiver, const char * method = 0 )<\/code>.<\/p>\n<p>So if you write <code>disconnect(object)<\/code>, you&#8217;re really disconnecting all signals received by <code>object<\/code>, not all signals sent by <code>object<\/code>.<\/p>\n<p>This tripped me up in a big way today; I was switching the slot a signal was connected to at run time as part of a simple state machine, and the state machine&#8217;s various slots were all being invoked! Not a nice situation, but easily solved by using the correct variant of <code>disconnect<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This was probably obvious to everyone except me&#8230; disconnect(object) is not the same as disconnect(object, 0, 0, 0) This makes perfect sense when you look at the overloaded function definitions for disconnect, one of which reads: bool QObject::disconnect ( const QObject * receiver, const char * method = 0 ). So if you write disconnect(object), &hellip; <a href=\"https:\/\/www.lothlorien.com\/kf6gpe\/are-your-signals-not-disconnecting\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Are your Qt signals not disconnecting?<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-375","post","type-post","status-publish","format-standard","hentry","category-mobile"],"_links":{"self":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/375"}],"collection":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/comments?post=375"}],"version-history":[{"count":3,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/375\/revisions"}],"predecessor-version":[{"id":378,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/posts\/375\/revisions\/378"}],"wp:attachment":[{"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/media?parent=375"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/categories?post=375"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lothlorien.com\/kf6gpe\/wp-json\/wp\/v2\/tags?post=375"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}