<?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[[Solved] Differentiating multiple signals going to a single slot]]></title><description><![CDATA[<p dir="auto">Here's some code that creates a list of 10 pushbuttons and connects the clicked singal of all of them to a single slot (on_pushButtonList_clicked)<br />
@<br />
for(index = 0; index &lt; 10; index++)<br />
{<br />
pushButton[index] = new QPushButton(this);<br />
pushButton[index]-&gt;resize(60, 40);<br />
pushButton[index]-&gt;move(400, 50 + 50 * index);<br />
pushButton[index]-&gt;setText(QString::number(index, 'g', 2));<br />
connect(pushButton[index], SIGNAL(clicked()), this, SLOT(on_pushButtonList_clicked()));<br />
}<br />
@<br />
When I get to the on_pushButtonList_clicked slot, how do I find out which button was clicked?  In addition to getting a pointer to the button that was hit, is there a way to get its index position (pushButton[0], pushButton[6], etc.)?</p>
]]></description><link>https://forum.qt.io/topic/17546/solved-differentiating-multiple-signals-going-to-a-single-slot</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 09:07:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/17546.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 14 Jun 2012 15:25:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Solved] Differentiating multiple signals going to a single slot on Thu, 14 Jun 2012 15:52:18 GMT]]></title><description><![CDATA[<p dir="auto">You can get pointer to pushbutton in slot by using QObject::sender() method.<br />
If you have access to pushButtonList (I suppose it's QList) you can get button index with<br />
pushButtonList.indexOf(sender()).</p>
<p dir="auto">If you don't have access to pushButtonList from slot you should check QSignalMapper as mlong suggested.</p>
]]></description><link>https://forum.qt.io/post/141723</link><guid isPermaLink="true">https://forum.qt.io/post/141723</guid><dc:creator><![CDATA[tolszak]]></dc:creator><pubDate>Thu, 14 Jun 2012 15:52:18 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] Differentiating multiple signals going to a single slot on Thu, 14 Jun 2012 15:27:43 GMT]]></title><description><![CDATA[<p dir="auto">Check out "QSignalMapper.":<a href="http://qt-project.org/doc/qt-4.8/qsignalmapper.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/qsignalmapper.html</a></p>
]]></description><link>https://forum.qt.io/post/141719</link><guid isPermaLink="true">https://forum.qt.io/post/141719</guid><dc:creator><![CDATA[mlong]]></dc:creator><pubDate>Thu, 14 Jun 2012 15:27:43 GMT</pubDate></item></channel></rss>