<?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[error connecting signal to slot in custom class]]></title><description><![CDATA[<p dir="auto">Hello, I am trying to connect a signal between a series in a custom chart class to a slot in said chart class like so:</p>
<pre><code>connect(series, SIGNAL(clicked(QPointF)), chart4Map, SLOT(pointClicked(QPointF)));
</code></pre>
<p dir="auto">mapChart</p>
<pre><code>class mapChart : public QChart
{
public slots:
    void pointClicked(const QPointF &amp;point);
};
</code></pre>
<p dir="auto">However when I do so I get the error <code>QObject::connect: No such slot QtCharts::QChart::pointClicked(QPointF)</code> which I don't understand as my chart4Map is a mapChart instance</p>
]]></description><link>https://forum.qt.io/topic/138390/error-connecting-signal-to-slot-in-custom-class</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 21:04:56 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/138390.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 05 Aug 2022 07:37:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 08:04:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/deneguil">@<bdi>Deneguil</bdi></a> said in <a href="/post/723885">error connecting signal to slot in custom class</a>:</p>
<blockquote>
<p dir="auto">However after changing it to <code>connect(series, &amp;QScatterSeries::clicked, chart4Map, &amp;mapChart::pointClicked);</code> it works now so I'm probably going to change every SIGNAL()/SLOT() in my code now too</p>
</blockquote>
<p dir="auto">:) :)  New style was introduced years &amp; years ago.  I know some old examples still use <code>SIGNAL</code>/<code>SLOT()</code>, but  assuming you are Qt5 onward you are really a lot better off with new style!</p>
]]></description><link>https://forum.qt.io/post/723888</link><guid isPermaLink="true">https://forum.qt.io/post/723888</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 05 Aug 2022 08:04:37 GMT</pubDate></item><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 08:00:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/723880">error connecting signal to slot in custom class</a>:</p>
<blockquote>
<p dir="auto">Since your slot signature parameter is <code>const QPointF &amp;point</code> it won't match the plain <code>QPointF</code> in your <code>SLOT()</code>.</p>
</blockquote>
<p dir="auto">I tried fixing the slot signature and adding the Q_OBJECT macro to my class as well and this time I got <code>QObject::connect: No such signal QtCharts::QScatterSeries::clicked(const QPointF &amp;point)</code> which seems weird to me since ScatterSeries should have the signal inhearited from XYSeries.</p>
<blockquote>
<p dir="auto">Why don't you use "new" (actually very old now!) signal/slot syntax, instead of <code>SIGNAL</code>/<code>SLOT()</code>, it gives more help on these errors?</p>
</blockquote>
<p dir="auto">There was no other reason than I'm pretty new to Qt development and so far that was the syntax that worked for me so I didn't see a reason to change.<br />
However after changing it to <code>connect(series, &amp;QScatterSeries::clicked, chart4Map, &amp;mapChart::pointClicked);</code> it works now so I'm probably going to change every SIGNAL()/SLOT() in my code now too</p>
<p dir="auto">Thank you all for your help</p>
]]></description><link>https://forum.qt.io/post/723885</link><guid isPermaLink="true">https://forum.qt.io/post/723885</guid><dc:creator><![CDATA[Deneguil]]></dc:creator><pubDate>Fri, 05 Aug 2022 08:00:28 GMT</pubDate></item><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 07:47:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/723883">error connecting signal to slot in custom class</a>:</p>
<blockquote>
<p dir="auto">I don't think it's mandatory for a slot in new style, at least?</p>
</blockquote>
<p dir="auto">you would be correct, the class containing the signal still requires it (I think)</p>
]]></description><link>https://forum.qt.io/post/723884</link><guid isPermaLink="true">https://forum.qt.io/post/723884</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 05 Aug 2022 07:47:11 GMT</pubDate></item><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 08:02:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/chrisw67">@<bdi>ChrisW67</bdi></a> said in <a href="/post/723881">error connecting signal to slot in custom class</a>:</p>
<blockquote>
<p dir="auto">The mapChart class presented is lacking a Q_OBJECT macro.</p>
</blockquote>
<p dir="auto">This is true, but <em>as far as I know</em> <code>Q_OBJECT</code> is not <em>required</em> for <em>slots</em>, only for <em>signals</em>?</p>
<p dir="auto">Am I not right that the <code>QPointF</code> will not match <code>const QPointF &amp;point</code>, and that is the error here?  [<strong>UPDATE</strong> Oh, @J-Hilk says Qt4 will match these similar-but-different signatures, so maybe I am wrong, and it is indeed somehow the <code>Q_OBJECT</code> missing for Qt4, sorry if my attempts at answering have been wrong, I have learned something about Qt4 now!  See also <a href="https://forum.qt.io/topic/115188/do-i-need-to-use-the-q_object-macro-if-i-only-use-slots">https://forum.qt.io/topic/115188/do-i-need-to-use-the-q_object-macro-if-i-only-use-slots</a>]</p>
<p dir="auto">@J-Hilk said in <a href="/post/723882">error connecting signal to slot in custom class</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/deneguil">@<bdi>Deneguil</bdi></a> you're using old(Qt4) signal slot syntax, so your class 100% requires Q_OBJECT macro to work.</p>
</blockquote>
<p dir="auto">Ah, I did not know that requirement!  I don't think it's mandatory for a <em>slot</em> in new style, at least?  One more reason for using new-style if not bound to Qt4!</p>
]]></description><link>https://forum.qt.io/post/723883</link><guid isPermaLink="true">https://forum.qt.io/post/723883</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 05 Aug 2022 08:02:38 GMT</pubDate></item><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 07:44:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/deneguil">@<bdi>Deneguil</bdi></a> you're using old(Qt4) signal slot syntax, so your class 100% requires Q_OBJECT macro to work.</p>
<p dir="auto">It is missing.</p>
]]></description><link>https://forum.qt.io/post/723882</link><guid isPermaLink="true">https://forum.qt.io/post/723882</guid><dc:creator><![CDATA[J.Hilk]]></dc:creator><pubDate>Fri, 05 Aug 2022 07:44:13 GMT</pubDate></item><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 07:43:44 GMT]]></title><description><![CDATA[<p dir="auto">The mapChart class presented is lacking a Q_OBJECT macro.<br />
Also, have you ensured that <code>moc</code> has run over the header declaring mapChart?</p>
]]></description><link>https://forum.qt.io/post/723881</link><guid isPermaLink="true">https://forum.qt.io/post/723881</guid><dc:creator><![CDATA[ChrisW67]]></dc:creator><pubDate>Fri, 05 Aug 2022 07:43:44 GMT</pubDate></item><item><title><![CDATA[Reply to error connecting signal to slot in custom class on Fri, 05 Aug 2022 07:43:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/deneguil">@<bdi>Deneguil</bdi></a><br />
Since your slot signature parameter is <code>const QPointF &amp;point</code> it won't match the plain <code>QPointF</code> in your <code>SLOT()</code>.</p>
<p dir="auto">Why don't you use "new" (actually very old now!) signal/slot syntax, instead of <code>SIGNAL</code>/<code>SLOT()</code>, it gives more help on these errors?</p>
]]></description><link>https://forum.qt.io/post/723880</link><guid isPermaLink="true">https://forum.qt.io/post/723880</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 05 Aug 2022 07:43:06 GMT</pubDate></item></channel></rss>