<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Which class should be used to connect a signal ?]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">As far as I know, the following lines should be equivalent :</p>
<pre><code>QObject::connect(ui-&gt;button, &amp;QPushButton::clicked, this, []() {});
QObject::connect(ui-&gt;button, &amp;QAbstractButton::clicked, this, []() {});
</code></pre>
<p dir="auto">Most examples and Qt sources tends to favor the first using the actual widget class. Does it make any difference ? And if there are, what are the benefits/drawbacks of both ?</p>
<p dir="auto">The second makes code less susceptible to UI changes (replacing QPushButton with QRadioButton for example), and in any case, if the class/method doesn't match, it would result in a build error. I don't know if this is even possible, but the derived class could hide the signal from the base class causing issues, no ?</p>
<p dir="auto">Thank you in advance !</p>
]]></description><link>https://forum.qt.io/topic/134420/which-class-should-be-used-to-connect-a-signal</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 16:34:05 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/134420.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 17 Feb 2022 14:31:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Which class should be used to connect a signal ? on Thu, 17 Feb 2022 14:46:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tudal">@<bdi>Tudal</bdi></a> said in <a href="/post/703013">Which class should be used to connect a signal ?</a>:</p>
<blockquote>
<p dir="auto">Does it make any difference ?</p>
</blockquote>
<p dir="auto">No, use what you like. I mostly use the class of the pointer before since I don't care in which base class the signal or slot is defined.</p>
]]></description><link>https://forum.qt.io/post/703016</link><guid isPermaLink="true">https://forum.qt.io/post/703016</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Thu, 17 Feb 2022 14:46:08 GMT</pubDate></item></channel></rss>