<?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[Passing multiple parameters to QProcess]]></title><description><![CDATA[<p dir="auto">I am having an issue with passing multiple parameters to QProcess  -&gt; QStringList.</p>
<p dir="auto">Is there a way to verify the actual contents of<br />
QStringList BEFORE running QProcess start?</p>
<p dir="auto">PS QProcess works, verified with connect error and status ,  with single params, but no leading or terminating spaces.</p>
<p dir="auto">QStringList params;<br />
params &lt;&lt; "-maximized"; //  works fine by itself<br />
params  &lt;&lt; "-e" &lt;&lt; "lsusb"; // QProcess starts but terminates<br />
//<br />
QP-&gt;start("xterm", params);&lt;/pre&gt;&lt;/pre&gt;</p>
]]></description><link>https://forum.qt.io/topic/153400/passing-multiple-parameters-to-qprocess</link><generator>RSS for Node</generator><lastBuildDate>Thu, 22 Oct 2026 00:42:45 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/153400.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 01 Jan 2024 21:00:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Passing multiple parameters to QProcess on Tue, 02 Jan 2024 16:57:18 GMT]]></title><description><![CDATA[<p dir="auto">@AnneRanch said in <a href="/post/784906">Passing multiple parameters to QProcess</a>:</p>
<blockquote>
<p dir="auto">params need to have only single item...</p>
</blockquote>
<p dir="auto">Not quite correct.<br />
<code>params</code> is a <code>QStringList</code>. A LIST of <code>QString</code>.<br />
With the <code>&lt;&lt;</code> operator you direct the right side to the left (i.e. the string list).</p>
<blockquote>
<p dir="auto">params need to have only single item...</p>
</blockquote>
<p dir="auto">So it's more like "You can add only one after another"<br />
(because <code>QProcess</code> needs every argument as separate string)</p>
<p dir="auto">As you might already know / have seen from <a class="plugin-mentions-user plugin-mentions-a" href="/user/axel-spoerl">@<bdi>Axel-Spoerl</bdi></a> 's suggestion to use <code>qDebug()</code></p>
<p dir="auto">This</p>
<pre><code>params &lt;&lt; "-fa";
params &lt;&lt; "Monospace";
params &lt;&lt; "-fs";
params &lt;&lt;"16";
</code></pre>
<p dir="auto">produces:</p>
<ul>
<li><code>QStringList("-fa")</code></li>
<li><code>QStringList("-fa", "Monospace")</code></li>
<li><code>QStringList("-fa", "Monospace", "-fs")</code></li>
<li><code>QStringList("-fa", "Monospace", "-fs", "16")</code></li>
</ul>
<p dir="auto">Each element is a <code>QString</code> and the next to-be-added item is appended to the end of the list.</p>
]]></description><link>https://forum.qt.io/post/784911</link><guid isPermaLink="true">https://forum.qt.io/post/784911</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Tue, 02 Jan 2024 16:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to Passing multiple parameters to QProcess on Tue, 02 Jan 2024 16:42:41 GMT]]></title><description><![CDATA[<p dir="auto">Partially solved.<br />
It helps to have understanding of QProcess and operator "&lt;&lt;".</p>
<p dir="auto">Or just paying attention what works...</p>
<p dir="auto">params need to have only single item...</p>
<pre><code> params &lt;&lt; "-fa";
    params &lt;&lt; "Monospace";
    params &lt;&lt; "-fs";
    params &lt;&lt;"16";

</code></pre>
]]></description><link>https://forum.qt.io/post/784906</link><guid isPermaLink="true">https://forum.qt.io/post/784906</guid><dc:creator><![CDATA[Anonymous_Banned275]]></dc:creator><pubDate>Tue, 02 Jan 2024 16:42:41 GMT</pubDate></item><item><title><![CDATA[Reply to Passing multiple parameters to QProcess on Tue, 02 Jan 2024 10:01:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/quadbyte">@<bdi>quadbyte</bdi></a><br />
I don't think OP is asking about retrieving output from the subprocess.  If she were there would be no reason to run an <strong>xterm</strong> to execute the <code>lsusb</code> process or whatever command, she would run it directly.  As discussed in other threads, you cannot retrieve output from an <strong>xterm</strong> process as it does not produce any to stdout/err etc., it handles it internally.</p>
<p dir="auto">@AnneRanch<br />
Your issue has nothing to do with multiple parameters, string lists or spaces.</p>
<blockquote>
<p dir="auto">Is there a way to verify the actual contents of</p>
<p dir="auto">QStringList BEFORE running QProcess start?</p>
</blockquote>
<p dir="auto">Of course.  Since you put the parameters into a <code>QStringList</code> variable you can <code>qDebug() &lt;&lt; params;</code>.  That tells you precisely what the contents are before you pass to <code>QProcess</code>, no more and no less than that.</p>
<blockquote>
<p dir="auto"><code>params &lt;&lt; "-e" &lt;&lt; "lsusb"; // QProcess starts but terminates</code></p>
</blockquote>
<p dir="auto">Well yes, because that is what you tell it to do with the <code>-e</code> argument.  <code>xterm -e whatever</code> says: start an <strong>xterm</strong>, run just and only <code>whatever</code> in it and then when that completes <em>exit the xterm</em>.  So as soon as your <code>lsusb</code> command finishes, which I guess is microseconds, the <strong>xterm</strong> process finishes, closes its window, and the <code>QProcess</code> receives finished and exit code from the <code>xterm</code>.  Tested with <code>xterm -e ls</code> it is so quick you don't even see the <strong>xterm</strong> appear and disappear.</p>
<p dir="auto">You can see this for yourself, nothing to do with Qt or <code>QProcess</code>.  In a terminal just run <code>xterm -e lsusb</code>.  You should effectively see nothing (because it's so fast), and you get back to the command prompt indicating that the <strong>xterm</strong> has exited.</p>
<p dir="auto">If you want to see what is really happening try a long-running command with lots of output: <code>xterm -e find / -print</code>.  See how you see all the output scroll, and when it gets to the end the <strong>xterm</strong> window closes and exits.</p>
<p dir="auto">I don't know what you intend to achieve via <code>xterm -e lsusb</code> other than than this behaviour.  If you perhaps want the <strong>xterm</strong> to run the <strong>lsusb</strong> command <em>and then stay open with its output</em> then ask for this, it would require a different command line to <strong>xterm</strong> using the <code>-hold</code> option:</p>
<pre><code>// from terminal
xterm -hold -e lsusb
// from Qt
params &lt;&lt; "-hold" &lt;&lt; "-e" &lt;&lt; "lsusb";
QP-&gt;start("xterm", params);
</code></pre>
<p dir="auto">This will run the <code>lsusb</code> and then hold the <strong>xterm</strong> window open waiting for you to manually close it.  The <code>QProcess</code> will not finish until you do so.</p>
]]></description><link>https://forum.qt.io/post/784859</link><guid isPermaLink="true">https://forum.qt.io/post/784859</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 02 Jan 2024 10:01:24 GMT</pubDate></item><item><title><![CDATA[Reply to Passing multiple parameters to QProcess on Tue, 02 Jan 2024 09:34:24 GMT]]></title><description><![CDATA[<p dir="auto">@AnneRanch said in <a href="/post/784801">Passing multiple parameters to QProcess</a>:</p>
<blockquote>
<p dir="auto">Is there a way to verify the actual contents of<br />
QStringList BEFORE running QProcess start?</p>
</blockquote>
<p dir="auto"><code>qDebug() &lt;&lt; params;</code></p>
]]></description><link>https://forum.qt.io/post/784856</link><guid isPermaLink="true">https://forum.qt.io/post/784856</guid><dc:creator><![CDATA[Axel Spoerl]]></dc:creator><pubDate>Tue, 02 Jan 2024 09:34:24 GMT</pubDate></item><item><title><![CDATA[Reply to Passing multiple parameters to QProcess on Mon, 01 Jan 2024 23:05:19 GMT]]></title><description><![CDATA[<p dir="auto">You can redirect standard output &amp; error that way:</p>
<pre><code>   QProcess ftp;   

   QObject::connect (&amp;ftp, &amp;QProcess::readyReadStandardOutput, [&amp;](){
      QByteArray data = ftp.readAllStandardOutput();
      auto coutList = data.split('\n');

      qDebug() &lt;&lt; coutList;
   });
   QObject::connect (&amp;ftp, &amp;QProcess::readyReadStandardError, [&amp;](){
      QByteArray data = ftp.readAllStandardError();
      auto coutList = data.split('\n');

      qDebug() &lt;&lt; coutList;
   });

   ftp.start("wget", QStringList() &lt;&lt; "-P" &lt;&lt; url.toString());
   return ftp.waitForFinished();
</code></pre>
]]></description><link>https://forum.qt.io/post/784809</link><guid isPermaLink="true">https://forum.qt.io/post/784809</guid><dc:creator><![CDATA[quadbyte]]></dc:creator><pubDate>Mon, 01 Jan 2024 23:05:19 GMT</pubDate></item></channel></rss>