<?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[where should action execution happen?]]></title><description><![CDATA[<p dir="auto">i have a module like class, which is <code>QObject</code>.<br />
the module creates a lot of actions.<br />
i don't want to add as much slots in the module, instead i want to create a class which consists of only public slots, for each of the actions.<br />
i want to know if this is a good pattern to use</p>
]]></description><link>https://forum.qt.io/topic/119774/where-should-action-execution-happen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 10:05:16 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/119774.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Oct 2020 14:37:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to where should action execution happen? on Fri, 09 Oct 2020 06:57:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/user4592357">@<bdi>user4592357</bdi></a> Usually a class which emits signals should not know anything about classes which connects to its signals. I suggest you provide an interface in your model to get the actions, then your main window can get these actions and connect to them - your model does not have to care about classes connecting to it.</p>
]]></description><link>https://forum.qt.io/post/621453</link><guid isPermaLink="true">https://forum.qt.io/post/621453</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Fri, 09 Oct 2020 06:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to where should action execution happen? on Thu, 08 Oct 2020 15:44:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
why is it bad? if my module is very smart thing, i may give it only to people who pay for it :)</p>
<p dir="auto">so it makes sense to add actions in module.</p>
<p dir="auto">so, should i create this new actionExecutor class and have public functions in it, and connect my actions to these functions?</p>
]]></description><link>https://forum.qt.io/post/621368</link><guid isPermaLink="true">https://forum.qt.io/post/621368</guid><dc:creator><![CDATA[user4592357]]></dc:creator><pubDate>Thu, 08 Oct 2020 15:44:57 GMT</pubDate></item><item><title><![CDATA[Reply to where should action execution happen? on Thu, 08 Oct 2020 15:25:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/user4592357">@<bdi>user4592357</bdi></a> said in <a href="/post/621362">where should action execution happen?</a>:</p>
<blockquote>
<p dir="auto">i have main window pointer and add the actions to main window from the module, so I can't place the slots in main window.</p>
</blockquote>
<p dir="auto">Precisely!  Which doesn't sound very good :)  It <em>sounds</em> like you have a number of widgets with actions and slots to do stuff all of which belong in/access members in your main window class?  In which case, trying to create some other module to offer the slots for the actions is likely to make it bad just as you are saying....</p>
]]></description><link>https://forum.qt.io/post/621363</link><guid isPermaLink="true">https://forum.qt.io/post/621363</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 08 Oct 2020 15:25:29 GMT</pubDate></item><item><title><![CDATA[Reply to where should action execution happen? on Thu, 08 Oct 2020 15:21:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
i have main window pointer and add the actions to main window from the module, so I can't place the slots in main window.</p>
<p dir="auto">neither i want to place them in module.<br />
so i thought i would need to create a new class, actionExecutor or whatever</p>
]]></description><link>https://forum.qt.io/post/621362</link><guid isPermaLink="true">https://forum.qt.io/post/621362</guid><dc:creator><![CDATA[user4592357]]></dc:creator><pubDate>Thu, 08 Oct 2020 15:21:38 GMT</pubDate></item><item><title><![CDATA[Reply to where should action execution happen? on Thu, 08 Oct 2020 14:51:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/user4592357">@<bdi>user4592357</bdi></a><br />
Slots would be best defined where the <em>body of the code they execute</em> is closest to the objects it needs to access.  For example, if your slots spend a lot of their time accessing objects/widgets defined in your <code>MainWindow</code> class, it's all very well putting them elsewhere as you say but then you are likely to have parameters to them to access the <code>MainWindow</code>, and possibly its private variables.  Which is not good.</p>
<p dir="auto">That is a separate question from whether you want to, say, derive your own class from <code>QAction</code> to use.  As usual with Qt signals/slots, the module which creates a <code>QAction</code> and <code>connect()</code>s its signals to slots must simply have visibility of both the signals and the desired slot objects.</p>
]]></description><link>https://forum.qt.io/post/621354</link><guid isPermaLink="true">https://forum.qt.io/post/621354</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 08 Oct 2020 14:51:56 GMT</pubDate></item></channel></rss>