<?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] How to make multi QPushButton to activate slot]]></title><description><![CDATA[<p dir="auto">Hello.</p>
<p dir="auto">I am trying to make a simple game that will have 9 QPushButtons. I am trying to make single conection that will have all 9 QpushButton and slot, and when I click the button, that button will change text, with help of slot.</p>
<p dir="auto">I have tried doing this like:<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/connect">@<bdi>connect</bdi></a>(button1 | button2 | button3 | button4 | button5 | button6 | button7 | button8 | button9 |, SIGNAL(clicked()), this, SLOT(buttonPressed()));@<br />
But it dosent work.</p>
<p dir="auto">Do you have some idea how can I do this???</p>
]]></description><link>https://forum.qt.io/topic/14240/solved-how-to-make-multi-qpushbutton-to-activate-slot</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 14:18:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/14240.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Feb 2012 11:57:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Solved] How to make multi QPushButton to activate slot on Mon, 20 Feb 2012 17:50:03 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much for help</p>
]]></description><link>https://forum.qt.io/post/129716</link><guid isPermaLink="true">https://forum.qt.io/post/129716</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 20 Feb 2012 17:50:03 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] How to make multi QPushButton to activate slot on Mon, 20 Feb 2012 14:42:25 GMT]]></title><description><![CDATA[<p dir="auto">You could keep using QSignalMapper for that, using the mapping to QWidget, but perhaps that gets a bit tedious. You could also use something like this:</p>
<p dir="auto">@<br />
MyClass::buttonClicked() {<br />
QAbstractButton* button = qobject_cast&lt;QAbstractButton*&gt;(sender());<br />
if (!button)<br />
return; // not called from button</p>
<p dir="auto">button-&gt;setText("Clicked");<br />
}<br />
@</p>
<p dir="auto">And then simply connect all the buttons clicked signals to this one slot.</p>
]]></description><link>https://forum.qt.io/post/129688</link><guid isPermaLink="true">https://forum.qt.io/post/129688</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Mon, 20 Feb 2012 14:42:25 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] How to make multi QPushButton to activate slot on Mon, 20 Feb 2012 14:31:30 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much for your help.</p>
<p dir="auto">I have made connections with QSignalMapper, but I still have one problem.</p>
<p dir="auto">I am trying to make a function that will on button click change text on the clicked button.</p>
<p dir="auto">So far I have made a function that changes text on button click but only on the last button, so when I click on the any button it will only change text on the last button.</p>
<p dir="auto">Can you please help me solve this problem.</p>
]]></description><link>https://forum.qt.io/post/129687</link><guid isPermaLink="true">https://forum.qt.io/post/129687</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 20 Feb 2012 14:31:30 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] How to make multi QPushButton to activate slot on Mon, 20 Feb 2012 12:19:56 GMT]]></title><description><![CDATA[<p dir="auto">If you need to differentiate between what button was clicked, you should also look into &lsqb;&lsqb;doc:QSignalMapper&rsqb;&rsqb;. Also note that you can use a loop to do the connects, if you don't want to make 9 connect statements in your code.</p>
]]></description><link>https://forum.qt.io/post/129668</link><guid isPermaLink="true">https://forum.qt.io/post/129668</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Mon, 20 Feb 2012 12:19:56 GMT</pubDate></item><item><title><![CDATA[Reply to [Solved] How to make multi QPushButton to activate slot on Mon, 20 Feb 2012 12:04:58 GMT]]></title><description><![CDATA[<p dir="auto">You need to have nine different connect statements, but you can connect those to the same slot.</p>
]]></description><link>https://forum.qt.io/post/129667</link><guid isPermaLink="true">https://forum.qt.io/post/129667</guid><dc:creator><![CDATA[koahnig]]></dc:creator><pubDate>Mon, 20 Feb 2012 12:04:58 GMT</pubDate></item></channel></rss>