<?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[Beyond accept() reject()]]></title><description><![CDATA[<p dir="auto">I have a dialog that includes an array of buttons that I want to trigger various actions. How can the program that calls the dialog determine exactly which button was pressed?  Ideally, I'd like any button press to close the dialog and then drop into something similar to a switch/case : button1, do this, button2, do that, button3 do the other... Right now one button is linked to accept() and another to reject(), which is kind of limiting.</p>
]]></description><link>https://forum.qt.io/topic/50524/beyond-accept-reject</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Mar 2026 03:56:23 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/50524.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Jan 2015 03:31:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Beyond accept() reject() on Mon, 26 Jan 2015 07:44:44 GMT]]></title><description><![CDATA[<p dir="auto">Also note that you can still access your dialog class after the user has made his choice. That means that you can also provide API on it to read any value you need.</p>
]]></description><link>https://forum.qt.io/post/259186</link><guid isPermaLink="true">https://forum.qt.io/post/259186</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Mon, 26 Jan 2015 07:44:44 GMT</pubDate></item><item><title><![CDATA[Reply to Beyond accept() reject() on Sun, 25 Jan 2015 21:57:58 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">You might also be interested by the "QDialogButtonBox":<a href="http://doc.qt.io/qt-5/qdialogbuttonbox.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qdialogbuttonbox.html</a> class</p>
]]></description><link>https://forum.qt.io/post/259158</link><guid isPermaLink="true">https://forum.qt.io/post/259158</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 25 Jan 2015 21:57:58 GMT</pubDate></item><item><title><![CDATA[Reply to Beyond accept() reject() on Sun, 25 Jan 2015 17:09:28 GMT]]></title><description><![CDATA[<p dir="auto">Got it, thanks. Each button when clicked assigns a value to my return code;  each button except for my cancel is connected to the accept() slot.  Seems to work fine :)</p>
]]></description><link>https://forum.qt.io/post/259132</link><guid isPermaLink="true">https://forum.qt.io/post/259132</guid><dc:creator><![CDATA[jocala]]></dc:creator><pubDate>Sun, 25 Jan 2015 17:09:28 GMT</pubDate></item><item><title><![CDATA[Reply to Beyond accept() reject() on Sun, 25 Jan 2015 08:02:53 GMT]]></title><description><![CDATA[<p dir="auto">Maybe you can make use of "finished()":<a href="http://doc.qt.io/qt-5/qdialog.html#finished" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qdialog.html#finished</a> instead of accepted()/rejected(). Just connect your buttons clicked()-signals to a short lambda (or a normal slot, should you want to avoid that) and you should be fine. A custom enum might be be a good idea, though.</p>
]]></description><link>https://forum.qt.io/post/259081</link><guid isPermaLink="true">https://forum.qt.io/post/259081</guid><dc:creator><![CDATA[thEClaw]]></dc:creator><pubDate>Sun, 25 Jan 2015 08:02:53 GMT</pubDate></item><item><title><![CDATA[Reply to Beyond accept() reject() on Sun, 25 Jan 2015 07:45:16 GMT]]></title><description><![CDATA[<p dir="auto">Accept is an indication that "some" action is to be taken, while reject means the user wants to cancel or "escape" from the dialog/decision entirely.<br />
Having said that all the buttons that "do something" should accept and set some flag to indicate which action was chosen.<br />
You could then check if the dialog was accepted, and if so, enter a switch/case to test the flag and decide which action to take.<br />
Either that or emit custom signals from the buttons clicks.</p>
]]></description><link>https://forum.qt.io/post/259079</link><guid isPermaLink="true">https://forum.qt.io/post/259079</guid><dc:creator><![CDATA[Chris Kawa]]></dc:creator><pubDate>Sun, 25 Jan 2015 07:45:16 GMT</pubDate></item></channel></rss>