<?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[How do i use the buttons from a vector of objects that have a member QPushButton * button in my Widget class?]]></title><description><![CDATA[<p dir="auto">So i have a class Territory that has a member QPushButton * button and i have a class Game that inherits a QWidget, here i want the game to take place. This class has a vector of objects of type Territory. And my question is how i can use those buttons? That appear on the screen, but i don't know how to make a clicked() function that can be used by all of them. For example if i click a territory to color it another color. How can i do that?</p>
]]></description><link>https://forum.qt.io/topic/141777/how-do-i-use-the-buttons-from-a-vector-of-objects-that-have-a-member-qpushbutton-button-in-my-widget-class</link><generator>RSS for Node</generator><lastBuildDate>Fri, 05 Jun 2026 10:04:33 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141777.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Dec 2022 21:23:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How do i use the buttons from a vector of objects that have a member QPushButton * button in my Widget class? on Wed, 28 Dec 2022 20:10:09 GMT]]></title><description><![CDATA[<p dir="auto">That worked, thanks!:3</p>
]]></description><link>https://forum.qt.io/post/741753</link><guid isPermaLink="true">https://forum.qt.io/post/741753</guid><dc:creator><![CDATA[Bebemc42]]></dc:creator><pubDate>Wed, 28 Dec 2022 20:10:09 GMT</pubDate></item><item><title><![CDATA[Reply to How do i use the buttons from a vector of objects that have a member QPushButton * button in my Widget class? on Tue, 27 Dec 2022 22:31:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bebemc42">@<bdi>Bebemc42</bdi></a><br />
Hello and welcome.</p>
<p dir="auto">If you have a number of buttons and you wish them to share a single <code>clicked</code> signal you might consider grouping them in a <a href="https://doc.qt.io/qt-6/qbuttongroup.html" target="_blank" rel="noopener noreferrer nofollow ugc">QButtonGroup</a> and attaching a slot to its <a href="https://doc.qt.io/qt-6/qbuttongroup.html#buttonClicked" target="_blank" rel="noopener noreferrer nofollow ugc">QButtonGroup::buttonClicked(QAbstractButton *button)</a> signal.</p>
<p dir="auto">Or you could iterate the vector calling <code>connect()</code> on each one in turn to the same slot, possibly with a parameter.</p>
]]></description><link>https://forum.qt.io/post/741630</link><guid isPermaLink="true">https://forum.qt.io/post/741630</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 27 Dec 2022 22:31:00 GMT</pubDate></item></channel></rss>