title: Starting an external program from a Qt application
body: <p>I'm trying to run a program to have it launch an external linux program in ubuntu 12.04.  The command works when it's typed into a terminal window but I can't seem to get it to work when it's placed into a clicked button object in QT 4.8.</p>
  
  <p>Here's the code that works when typed in a terminal window.  (It access the webcam and uses the overlay).  What I'm trying to do is whenever a button is pressed it will take a picture of the webcam and save the image using the date and time as filenames)</p>
  
  <pre><code>gst-launch-0.10 v4l2src ! video/x-raw-yuv, width=640, height=480  ! timeoverlay halignment=right valignment=bottom shaded-background=true ! clockoverlay halignment=left valignment=bottom text="M/D/Y:" shaded-background=true time-format="%m/%d/%Y %H:%M:%S" ! autovideosink
  </code></pre>
  
  <p>I was following the document 
  <strong>HOWTO: Start an external program from a Qt application</strong><br>
  <a href="http://www.qtforum.org/article/3079/howto-start-an-external-program-from-a-qt-application.html" rel="nofollow">http://www.qtforum.org/article/3079/howto-start-an-external-program-from-a-qt-application.html</a></p>
  
  <p>But when I add the code to the push button in QT</p>
  
  <pre><code>void runprg2::on_pushButton_clicked()
  {
      commandAndParameters&lt;&lt;"gst-launch-0.10 v4l2src ! video/x-raw-yuv, width=640, height=480  ! timeoverlay halignment=right valignment=bottom shaded-background=true ! clockoverlay halignment=left valignment=bottom text="M/D/Y:" shaded-background=true time-format="%m/%d/%Y %H:%M:%S" ! autovideosink";
  }
  </code></pre>
  
  <p>It doesn't compile and I get errors.  Is this tutorial correct?</p>
  
  <p>See Errors</p>
  
  <pre><code>../test3/main.cpp: In function 'int main(int, char**)':
  ../test3/main.cpp:23:26: error: expected primary-expression before '&lt;&lt;' token
  ../test3/main.cpp:28:48: error: no matching function for call to 'QProcess::QProcess(QStringList&amp;)'
  ../test3/main.cpp:28:48: note: candidates are:
  /usr/include/qt4/QtCore/qprocess.h:228:5: note: QProcess::QProcess(const QProcess&amp;)
  /usr/include/qt4/QtCore/qprocess.h:228:5: note:   no known conversion for argument 1 from 'QStringList' to 'const QProcess&amp;'
  /usr/include/qt4/QtCore/qprocess.h:133:14: note: QProcess::QProcess(QObject*)
  /usr/include/qt4/QtCore/qprocess.h:133:14: note:   no known conversion for argument 1 from 'QStringList' to 'QObject*'
  ../test3/main.cpp:31:25: error: no matching function for call to 'QProcess::start()'
  ../test3/main.cpp:31:25: note: candidates are:
  /usr/include/qt4/QtCore/qprocess.h:136:10: note: void QProcess::start(const QString&amp;, const QStringList&amp;, QIODevice::OpenMode)
  /usr/include/qt4/QtCore/qprocess.h:136:10: note:   candidate expects 3 arguments, 0 provided
  /usr/include/qt4/QtCore/qprocess.h:137:10: note: void QProcess::start(const QString&amp;, QIODevice::OpenMode)
  /usr/include/qt4/QtCore/qprocess.h:137:10: note:   candidate expects 2 arguments, 0 provided
  make: *** [main.o] Error 1
  </code></pre>
  
  <p>I didn't think posting all the code was proper etiquette so I just posted the error and the push button code that I had an issue with. Should I post all the code?</p>
  
  <p>Here's the main.cpp if this helps</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include "mainwindow.h"
  #include &lt;qapplication.h&gt;
  #include &lt;qprocess.h&gt;
  #include &lt;qstringlist.h&gt;
  
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      MainWindow w;
      w.show();
  
      // Set up the command line which starts the external program as QStringList.
          QStringList commandAndParameters;
  
          /* Fill in the following things:
           * - Name of program to execute.
           * - Every option needed by the program.
           * Attention: be aware of any strange options you pass to the program, e.g.
           * IP addresses. Quoting these options will usually help.
           */
         // commandAndParameters&lt;&lt;"konqueror"
                           &lt;&lt;"file:/home/thomas";
  
          /* Create a QProcess instance. It does not matter if it is created on the stack or
           * on the heap. - Ahem, I tested it on Linux only. :-)
           */
          QProcess myProcess(commandAndParameters);
  
          // Start the QProcess instance.
          myProcess.start();
  
          /* O.k., everything is fine now, leave the Qt application. The external program
           * will continue running.
           */
          return 0;
  
      return a.exec();
  }
  </code></pre>