Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 6192

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qprocess.cpp -->
  <title>Qt 4.8: QProcess Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtcore.html">QtCore</a></li>
<li>QProcess</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#running-a-process">Running a Process</a></li>
<li class="level2"><a href="#communicating-via-channels">Communicating via Channels</a></li>
<li class="level2"><a href="#synchronous-process-api">Synchronous Process API</a></li>
<li class="level2"><a href="#notes-for-windows-users">Notes for Windows Users</a></li>
<li class="level2"><a href="#symbian-platform-security-requirements">Symbian Platform Security Requirements</a></li>
</ul>
</div>
<h1 class="title">QProcess Class Reference</h1>
<!-- $$$QProcess-brief -->
<p>The QProcess class is used to start external programs and to communicate with them. <a href="#details">More...</a></p>
<!-- @@@QProcess -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QProcess&gt;</span></pre><p><b>Inherits: </b><a href="qiodevice.html">QIODevice</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qprocess-members.html">List of all members, including inherited members</a></li>
<li><a href="qprocess-obsolete.html">Obsolete members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#ExitStatus-enum">ExitStatus</a></b> { NormalExit, CrashExit }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#ProcessChannel-enum">ProcessChannel</a></b> { StandardOutput, StandardError }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#ProcessChannelMode-enum">ProcessChannelMode</a></b> { SeparateChannels, MergedChannels, ForwardedChannels }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#ProcessError-enum">ProcessError</a></b> { FailedToStart, Crashed, Timedout, WriteError, ReadError, UnknownError }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#ProcessState-enum">ProcessState</a></b> { NotRunning, Starting, Running }</td></tr>
</table>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#QProcess">QProcess</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#dtor.QProcess">~QProcess</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#closeReadChannel">closeReadChannel</a></b> ( ProcessChannel <i>channel</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#closeWriteChannel">closeWriteChannel</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#environment">environment</a></b> () const<tt> (deprecated)</tt></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QProcess::ProcessError </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#error">error</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#exitCode">exitCode</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QProcess::ExitStatus </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#exitStatus">exitStatus</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#nativeArguments">nativeArguments</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Q_PID </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#pid">pid</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> ProcessChannelMode </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#processChannelMode">processChannelMode</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QProcessEnvironment </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#processEnvironment">processEnvironment</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#readAllStandardError">readAllStandardError</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#readAllStandardOutput">readAllStandardOutput</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> ProcessChannel </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#readChannel">readChannel</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setEnvironment">setEnvironment</a></b> ( const QStringList &amp; <i>environment</i> )<tt> (deprecated)</tt></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setNativeArguments">setNativeArguments</a></b> ( const QString &amp; <i>arguments</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setProcessChannelMode">setProcessChannelMode</a></b> ( ProcessChannelMode <i>mode</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setProcessEnvironment">setProcessEnvironment</a></b> ( const QProcessEnvironment &amp; <i>environment</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setReadChannel">setReadChannel</a></b> ( ProcessChannel <i>channel</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setStandardErrorFile">setStandardErrorFile</a></b> ( const QString &amp; <i>fileName</i>, OpenMode <i>mode</i> = Truncate )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setStandardInputFile">setStandardInputFile</a></b> ( const QString &amp; <i>fileName</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setStandardOutputFile">setStandardOutputFile</a></b> ( const QString &amp; <i>fileName</i>, OpenMode <i>mode</i> = Truncate )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setStandardOutputProcess">setStandardOutputProcess</a></b> ( QProcess * <i>destination</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setWorkingDirectory">setWorkingDirectory</a></b> ( const QString &amp; <i>dir</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#start">start</a></b> ( const QString &amp; <i>program</i>, const QStringList &amp; <i>arguments</i>, OpenMode <i>mode</i> = ReadWrite )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#start-2">start</a></b> ( const QString &amp; <i>program</i>, OpenMode <i>mode</i> = ReadWrite )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QProcess::ProcessState </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#state">state</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#waitForFinished">waitForFinished</a></b> ( int <i>msecs</i> = 30000 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#waitForStarted">waitForStarted</a></b> ( int <i>msecs</i> = 30000 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#workingDirectory">workingDirectory</a></b> () const</td></tr>
</table>
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#atEnd">atEnd</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#bytesAvailable">bytesAvailable</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#bytesToWrite">bytesToWrite</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#canReadLine">canReadLine</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#close">close</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#isSequential">isSequential</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#waitForBytesWritten">waitForBytesWritten</a></b> ( int <i>msecs</i> = 30000 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#waitForReadyRead">waitForReadyRead</a></b> ( int <i>msecs</i> = 30000 )</td></tr>
</table>
<ul>
<li class="fn">33 public functions inherited from <a href="qiodevice.html#public-functions">QIODevice</a></li>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2>Public Slots</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#kill">kill</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#terminate">terminate</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#error-2">error</a></b> ( QProcess::ProcessError <i>error</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#finished">finished</a></b> ( int <i>exitCode</i>, QProcess::ExitStatus <i>exitStatus</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#readyReadStandardError">readyReadStandardError</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#readyReadStandardOutput">readyReadStandardOutput</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#started">started</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#stateChanged">stateChanged</a></b> ( QProcess::ProcessState <i>newState</i> )</td></tr>
</table>
<ul>
<li class="fn">4 signals inherited from <a href="qiodevice.html#signals">QIODevice</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#execute">execute</a></b> ( const QString &amp; <i>program</i>, const QStringList &amp; <i>arguments</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#execute-2">execute</a></b> ( const QString &amp; <i>program</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#startDetached">startDetached</a></b> ( const QString &amp; <i>program</i>, const QStringList &amp; <i>arguments</i>, const QString &amp; <i>workingDirectory</i>, qint64 * <i>pid</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#startDetached-2">startDetached</a></b> ( const QString &amp; <i>program</i>, const QStringList &amp; <i>arguments</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#startDetached-3">startDetached</a></b> ( const QString &amp; <i>program</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#systemEnvironment">systemEnvironment</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setProcessState">setProcessState</a></b> ( ProcessState <i>state</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#setupChildProcess">setupChildProcess</a></b> ()</td></tr>
</table>
<a name="reimplemented-protected-functions"></a>
<h2>Reimplemented Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#readData">readData</a></b> ( char * <i>data</i>, qint64 <i>maxlen</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual qint64 </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#writeData">writeData</a></b> ( const char * <i>data</i>, qint64 <i>len</i> )</td></tr>
</table>
<ul>
<li class="fn">5 protected functions inherited from <a href="qiodevice.html#protected-functions">QIODevice</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qprocess.html#Q_PID-typedef">Q_PID</a></b></td></tr>
</table>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QProcess-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QProcess class is used to start external programs and to communicate with them.</p>
<a name="running-a-process"></a>
<h3>Running a Process</h3>
<p>To start a process, pass the name and command line arguments of the program you want to run as arguments to <a href="qprocess.html#start">start</a>(). Arguments are supplied as individual strings in a <a href="qstringlist.html">QStringList</a>.</p>
<p>For example, the following code snippet runs the analog clock example in the Motif style on X11 platforms by passing strings containing &quot;-style&quot; and &quot;motif&quot; as two items in the list of arguments:</p>
<pre class="cpp">     <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent;
     ...
     <span class="type"><a href="qstring.html">QString</a></span> program <span class="operator">=</span> <span class="string">&quot;./path/to/Qt/examples/widgets/analogclock&quot;</span>;
     <span class="type"><a href="qstringlist.html">QStringList</a></span> arguments;
     arguments <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;-style&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;motif&quot;</span>;

     <span class="type">QProcess</span> <span class="operator">*</span>myProcess <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QProcess</span>(parent);
     myProcess<span class="operator">-</span><span class="operator">&gt;</span>start(program<span class="operator">,</span> arguments);</pre>
<p>QProcess then enters the <a href="qprocess.html#ProcessState-enum">Starting</a> state, and when the program has started, QProcess enters the <a href="qprocess.html#ProcessState-enum">Running</a> state and emits <a href="qprocess.html#started">started</a>().</p>
<p>QProcess allows you to treat a process as a sequential I/O device. You can write to and read from the process just as you would access a network connection using <a href="qtcpsocket.html">QTcpSocket</a>. You can then write to the process's standard input by calling <a href="qiodevice.html#write">write</a>(), and read the standard output by calling <a href="qiodevice.html#read">read</a>(), <a href="qiodevice.html#readLine">readLine</a>(), and <a href="qiodevice.html#getChar">getChar</a>(). Because it inherits <a href="qiodevice.html">QIODevice</a>, QProcess can also be used as an input source for <a href="qxmlreader.html">QXmlReader</a>, or for generating data to be uploaded using <a href="qftp.html">QFtp</a>.</p>
<p><b>Note:</b> On Windows CE and Symbian, reading and writing to a process is not supported.</p>
<p>When the process exits, QProcess reenters the <a href="qprocess.html#ProcessState-enum">NotRunning</a> state (the initial state), and emits <a href="qprocess.html#finished">finished</a>().</p>
<p>The <a href="qprocess.html#finished">finished</a>() signal provides the exit code and exit status of the process as arguments, and you can also call <a href="qprocess.html#exitCode">exitCode</a>() to obtain the exit code of the last process that finished, and <a href="qprocess.html#exitStatus">exitStatus</a>() to obtain its exit status. If an error occurs at any point in time, QProcess will emit the <a href="qprocess.html#error">error</a>() signal. You can also call <a href="qprocess.html#error">error</a>() to find the type of error that occurred last, and <a href="qprocess.html#state">state</a>() to find the current process state.</p>
<a name="communicating-via-channels"></a>
<h3>Communicating via Channels</h3>
<p>Processes have two predefined output channels: The standard output channel (<tt>stdout</tt>) supplies regular console output, and the standard error channel (<tt>stderr</tt>) usually supplies the errors that are printed by the process. These channels represent two separate streams of data. You can toggle between them by calling <a href="qprocess.html#setReadChannel">setReadChannel</a>(). QProcess emits <a href="qiodevice.html#readyRead">readyRead</a>() when data is available on the current read channel. It also emits <a href="qprocess.html#readyReadStandardOutput">readyReadStandardOutput</a>() when new standard output data is available, and when new standard error data is available, <a href="qprocess.html#readyReadStandardError">readyReadStandardError</a>() is emitted. Instead of calling <a href="qiodevice.html#read">read</a>(), <a href="qiodevice.html#readLine">readLine</a>(), or <a href="qiodevice.html#getChar">getChar</a>(), you can explicitly read all data from either of the two channels by calling <a href="qprocess.html#readAllStandardOutput">readAllStandardOutput</a>() or <a href="qprocess.html#readAllStandardError">readAllStandardError</a>().</p>
<p>The terminology for the channels can be misleading. Be aware that the process's output channels correspond to QProcess's <i>read</i> channels, whereas the process's input channels correspond to QProcess's <i>write</i> channels. This is because what we read using QProcess is the process's output, and what we write becomes the process's input.</p>
<p>QProcess can merge the two output channels, so that standard output and standard error data from the running process both use the standard output channel. Call <a href="qprocess.html#setProcessChannelMode">setProcessChannelMode</a>() with <a href="qprocess.html#ProcessChannelMode-enum">MergedChannels</a> before starting the process to activative this feature. You also have the option of forwarding the output of the running process to the calling, main process, by passing <a href="qprocess.html#ProcessChannelMode-enum">ForwardedChannels</a> as the argument.</p>
<p>Certain processes need special environment settings in order to operate. You can set environment variables for your process by calling <a href="qprocess.html#setEnvironment">setEnvironment</a>(). To set a working directory, call <a href="qprocess.html#setWorkingDirectory">setWorkingDirectory</a>(). By default, processes are run in the current working directory of the calling process.</p>
<p><b>Note:</b> On Symbian, setting environment or working directory is not supported. The working directory will always be the private directory of the running process.</p>
<p><b>Note:</b> On QNX, setting the working directory may cause all application threads, with the exception of the QProcess caller thread, to temporarily freeze, owing to a limitation in the operating system.</p>
<a name="synchronous-process-api"></a>
<h3>Synchronous Process API</h3>
<p>QProcess provides a set of functions which allow it to be used without an event loop, by suspending the calling thread until certain signals are emitted:</p>
<ul>
<li><a href="qprocess.html#waitForStarted">waitForStarted</a>() blocks until the process has started.</li>
<li><a href="qprocess.html#waitForReadyRead">waitForReadyRead</a>() blocks until new data is available for reading on the current read channel.</li>
<li><a href="qprocess.html#waitForBytesWritten">waitForBytesWritten</a>() blocks until one payload of data has been written to the process.</li>
<li><a href="qprocess.html#waitForFinished">waitForFinished</a>() blocks until the process has finished.</li>
</ul>
<p>Calling these functions from the main thread (the thread that calls <a href="qapplication.html#exec">QApplication::exec</a>()) may cause your user interface to freeze.</p>
<p>The following example runs <tt>gzip</tt> to compress the string &quot;Qt rocks!&quot;, without an event loop:</p>
<pre class="cpp">     <span class="type">QProcess</span> gzip;
     gzip<span class="operator">.</span>start(<span class="string">&quot;gzip&quot;</span><span class="operator">,</span> <span class="type"><a href="qstringlist.html">QStringList</a></span>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;-c&quot;</span>);
     <span class="keyword">if</span> (<span class="operator">!</span>gzip<span class="operator">.</span>waitForStarted())
         <span class="keyword">return</span> <span class="keyword">false</span>;

     gzip<span class="operator">.</span>write(<span class="string">&quot;Qt rocks!&quot;</span>);
     gzip<span class="operator">.</span>closeWriteChannel();

     <span class="keyword">if</span> (<span class="operator">!</span>gzip<span class="operator">.</span>waitForFinished())
         <span class="keyword">return</span> <span class="keyword">false</span>;

     <span class="type"><a href="qbytearray.html">QByteArray</a></span> result <span class="operator">=</span> gzip<span class="operator">.</span>readAll();</pre>
<a name="notes-for-windows-users"></a>
<h3>Notes for Windows Users</h3>
<p>Some Windows commands (for example, <tt>dir</tt>) are not provided by separate applications, but by the command interpreter itself. If you attempt to use QProcess to execute these commands directly, it won't work. One possible solution is to execute the command interpreter itself (<tt>cmd.exe</tt> on some Windows systems), and ask the interpreter to execute the desired command.</p>
<a name="symbian-platform-security-requirements"></a>
<h3>Symbian Platform Security Requirements</h3>
<p>On Symbian, processes which use the functions <a href="qprocess.html#kill">kill</a>() or <a href="qprocess.html#terminate">terminate</a>() must have the <tt>PowerMgmt</tt> platform security capability. If the client process lacks this capability, these functions will fail.</p>
<p>Platform security capabilities are added via the <a href="qmake-variable-reference.html#target-capability">TARGET.CAPABILITY</a> qmake variable.</p>
</div>
<p><b>See also </b><a href="qbuffer.html">QBuffer</a>, <a href="qfile.html">QFile</a>, and <a href="qtcpsocket.html">QTcpSocket</a>.</p>
<!-- @@@QProcess -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ExitStatus$$$NormalExit$$$CrashExit -->
<h3 class="fn"><a name="ExitStatus-enum"></a>enum QProcess::<span class="name">ExitStatus</span></h3>
<p>This enum describes the different exit statuses of <a href="qprocess.html">QProcess</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QProcess::NormalExit</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The process exited normally.</td></tr>
<tr><td class="topAlign"><tt>QProcess::CrashExit</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The process crashed.</td></tr>
</table>
<p><b>See also </b><a href="qprocess.html#exitStatus">exitStatus</a>().</p>
<!-- @@@ExitStatus -->
<!-- $$$ProcessChannel$$$StandardOutput$$$StandardError -->
<h3 class="fn"><a name="ProcessChannel-enum"></a>enum QProcess::<span class="name">ProcessChannel</span></h3>
<p>This enum describes the process channels used by the running process. Pass one of these values to <a href="qprocess.html#setReadChannel">setReadChannel</a>() to set the current read channel of <a href="qprocess.html">QProcess</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QProcess::StandardOutput</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The standard output (stdout) of the running process.</td></tr>
<tr><td class="topAlign"><tt>QProcess::StandardError</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The standard error (stderr) of the running process.</td></tr>
</table>
<p><b>See also </b><a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@ProcessChannel -->
<!-- $$$ProcessChannelMode$$$SeparateChannels$$$MergedChannels$$$ForwardedChannels -->
<h3 class="fn"><a name="ProcessChannelMode-enum"></a>enum QProcess::<span class="name">ProcessChannelMode</span></h3>
<p>This enum describes the process channel modes of <a href="qprocess.html">QProcess</a>. Pass one of these values to <a href="qprocess.html#setProcessChannelMode">setProcessChannelMode</a>() to set the current read channel mode.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QProcess::SeparateChannels</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign"><a href="qprocess.html">QProcess</a> manages the output of the running process, keeping standard output and standard error data in separate internal buffers. You can select the <a href="qprocess.html">QProcess</a>'s current read channel by calling <a href="qprocess.html#setReadChannel">setReadChannel</a>(). This is the default channel mode of <a href="qprocess.html">QProcess</a>.</td></tr>
<tr><td class="topAlign"><tt>QProcess::MergedChannels</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign"><a href="qprocess.html">QProcess</a> merges the output of the running process into the standard output channel (<tt>stdout</tt>). The standard error channel (<tt>stderr</tt>) will not receive any data. The standard output and standard error data of the running process are interleaved.</td></tr>
<tr><td class="topAlign"><tt>QProcess::ForwardedChannels</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign"><a href="qprocess.html">QProcess</a> forwards the output of the running process onto the main process. Anything the child process writes to its standard output and standard error will be written to the standard output and standard error of the main process.</td></tr>
</table>
<p><b>See also </b><a href="qprocess.html#setProcessChannelMode">setProcessChannelMode</a>().</p>
<!-- @@@ProcessChannelMode -->
<!-- $$$ProcessError$$$FailedToStart$$$Crashed$$$Timedout$$$ReadError$$$WriteError$$$UnknownError -->
<h3 class="fn"><a name="ProcessError-enum"></a>enum QProcess::<span class="name">ProcessError</span></h3>
<p>This enum describes the different types of errors that are reported by <a href="qprocess.html">QProcess</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QProcess::FailedToStart</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.</td></tr>
<tr><td class="topAlign"><tt>QProcess::Crashed</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The process crashed some time after starting successfully.</td></tr>
<tr><td class="topAlign"><tt>QProcess::Timedout</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The last waitFor...() function timed out. The state of <a href="qprocess.html">QProcess</a> is unchanged, and you can try calling waitFor...() again.</td></tr>
<tr><td class="topAlign"><tt>QProcess::WriteError</tt></td><td class="topAlign"><tt>4</tt></td><td class="topAlign">An error occurred when attempting to write to the process. For example, the process may not be running, or it may have closed its input channel.</td></tr>
<tr><td class="topAlign"><tt>QProcess::ReadError</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">An error occurred when attempting to read from the process. For example, the process may not be running.</td></tr>
<tr><td class="topAlign"><tt>QProcess::UnknownError</tt></td><td class="topAlign"><tt>5</tt></td><td class="topAlign">An unknown error occurred. This is the default return value of <a href="qprocess.html#error">error</a>().</td></tr>
</table>
<p><b>See also </b><a href="qprocess.html#error">error</a>().</p>
<!-- @@@ProcessError -->
<!-- $$$ProcessState$$$NotRunning$$$Starting$$$Running -->
<h3 class="fn"><a name="ProcessState-enum"></a>enum QProcess::<span class="name">ProcessState</span></h3>
<p>This enum describes the different states of <a href="qprocess.html">QProcess</a>.</p>
<table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><tt>QProcess::NotRunning</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The process is not running.</td></tr>
<tr><td class="topAlign"><tt>QProcess::Starting</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The process is starting, but the program has not yet been invoked.</td></tr>
<tr><td class="topAlign"><tt>QProcess::Running</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">The process is running and is ready for reading and writing.</td></tr>
</table>
<p><b>See also </b><a href="qprocess.html#state">state</a>().</p>
<!-- @@@ProcessState -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QProcess[overload1]$$$QProcessQObject* -->
<h3 class="fn"><a name="QProcess"></a>QProcess::<span class="name">QProcess</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a <a href="qprocess.html">QProcess</a> object with the given <i>parent</i>.</p>
<!-- @@@QProcess -->
<!-- $$$~QProcess[overload1]$$$~QProcess -->
<h3 class="fn"><a name="dtor.QProcess"></a>QProcess::<span class="name">~QProcess</span> ()<tt> [virtual]</tt></h3>
<p>Destructs the <a href="qprocess.html">QProcess</a> object, i.e&#x2e;, killing the process.</p>
<p>Note that this function will not return until the process is terminated.</p>
<!-- @@@~QProcess -->
<!-- $$$atEnd[overload1]$$$atEnd -->
<h3 class="fn"><a name="atEnd"></a><span class="type">bool</span> QProcess::<span class="name">atEnd</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#atEnd">QIODevice::atEnd</a>().</p>
<p>Returns true if the process is not running, and no more data is available for reading; otherwise returns false.</p>
<!-- @@@atEnd -->
<!-- $$$bytesAvailable[overload1]$$$bytesAvailable -->
<h3 class="fn"><a name="bytesAvailable"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QProcess::<span class="name">bytesAvailable</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#bytesAvailable">QIODevice::bytesAvailable</a>().</p>
<!-- @@@bytesAvailable -->
<!-- $$$bytesToWrite[overload1]$$$bytesToWrite -->
<h3 class="fn"><a name="bytesToWrite"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QProcess::<span class="name">bytesToWrite</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#bytesToWrite">QIODevice::bytesToWrite</a>().</p>
<!-- @@@bytesToWrite -->
<!-- $$$canReadLine[overload1]$$$canReadLine -->
<h3 class="fn"><a name="canReadLine"></a><span class="type">bool</span> QProcess::<span class="name">canReadLine</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#canReadLine">QIODevice::canReadLine</a>().</p>
<p>This function operates on the current read channel.</p>
<p><b>See also </b><a href="qprocess.html#readChannel">readChannel</a>() and <a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@canReadLine -->
<!-- $$$close[overload1]$$$close -->
<h3 class="fn"><a name="close"></a><span class="type">void</span> QProcess::<span class="name">close</span> ()<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#close">QIODevice::close</a>().</p>
<p>Closes all communication with the process and kills it. After calling this function, <a href="qprocess.html">QProcess</a> will no longer emit <a href="qiodevice.html#readyRead">readyRead</a>(), and data can no longer be read or written.</p>
<!-- @@@close -->
<!-- $$$closeReadChannel[overload1]$$$closeReadChannelProcessChannel -->
<h3 class="fn"><a name="closeReadChannel"></a><span class="type">void</span> QProcess::<span class="name">closeReadChannel</span> ( <span class="type"><a href="qprocess.html#ProcessChannel-enum">ProcessChannel</a></span> <i>channel</i> )</h3>
<p>Closes the read channel <i>channel</i>. After calling this function, <a href="qprocess.html">QProcess</a> will no longer receive data on the channel. Any data that has already been received is still available for reading.</p>
<p>Call this function to save memory, if you are not interested in the output of the process.</p>
<p><b>See also </b><a href="qprocess.html#closeWriteChannel">closeWriteChannel</a>() and <a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@closeReadChannel -->
<!-- $$$closeWriteChannel[overload1]$$$closeWriteChannel -->
<h3 class="fn"><a name="closeWriteChannel"></a><span class="type">void</span> QProcess::<span class="name">closeWriteChannel</span> ()</h3>
<p>Schedules the write channel of <a href="qprocess.html">QProcess</a> to be closed. The channel will close once all data has been written to the process. After calling this function, any attempts to write to the process will fail.</p>
<p>Closing the write channel is necessary for programs that read input data until the channel has been closed. For example, the program &quot;more&quot; is used to display text data in a console on both Unix and Windows. But it will not display the text data until <a href="qprocess.html">QProcess</a>'s write channel has been closed. Example:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> more;
 more<span class="operator">.</span>start(<span class="string">&quot;more&quot;</span>);
 more<span class="operator">.</span>write(<span class="string">&quot;Text to display&quot;</span>);
 more<span class="operator">.</span>closeWriteChannel();
 <span class="comment">// QProcess will emit readyRead() once &quot;more&quot; starts printing</span></pre>
<p>The write channel is implicitly opened when <a href="qprocess.html#start">start</a>() is called.</p>
<p><b>See also </b><a href="qprocess.html#closeReadChannel">closeReadChannel</a>().</p>
<!-- @@@closeWriteChannel -->
<!-- $$$environment[overload1]$$$environment -->
<h3 class="fn"><a name="environment"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QProcess::<span class="name">environment</span> () const</h3>
<p>This function is deprecated.</p>
<p>Returns the environment that <a href="qprocess.html">QProcess</a> will use when starting a process, or an empty <a href="qstringlist.html">QStringList</a> if no environment has been set using <a href="qprocess.html#setEnvironment">setEnvironment</a>() or setEnvironmentHash(). If no environment has been set, the environment of the calling process will be used.</p>
<p><b>Note:</b> The environment settings are ignored on Windows CE and Symbian, as there is no concept of an environment.</p>
<p><b>See also </b><a href="qprocess.html#processEnvironment">processEnvironment</a>(), <a href="qprocess.html#setEnvironment">setEnvironment</a>(), and <a href="qprocess.html#systemEnvironment">systemEnvironment</a>().</p>
<!-- @@@environment -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn"><a name="error"></a><span class="type"><a href="qprocess.html#ProcessError-enum">QProcess::ProcessError</a></span> QProcess::<span class="name">error</span> () const</h3>
<p>Returns the type of error that occurred last.</p>
<p><b>See also </b><a href="qprocess.html#state">state</a>().</p>
<!-- @@@error -->
<!-- $$$error$$$errorQProcess::ProcessError -->
<h3 class="fn"><a name="error-2"></a><span class="type">void</span> QProcess::<span class="name">error</span> ( <span class="type"><a href="qprocess.html#ProcessError-enum">QProcess::ProcessError</a></span> <i>error</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted when an error occurs with the process. The specified <i>error</i> describes the type of error that occurred.</p>
<!-- @@@error -->
<!-- $$$execute[overload1]$$$executeconstQString&constQStringList& -->
<h3 class="fn"><a name="execute"></a><span class="type">int</span> QProcess::<span class="name">execute</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i>, const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp; <i>arguments</i> )<tt> [static]</tt></h3>
<p>Starts the program <i>program</i> with the arguments <i>arguments</i> in a new process, waits for it to finish, and then returns the exit code of the process. Any data the new process writes to the console is forwarded to the calling process.</p>
<p>The environment and working directory are inherited from the calling process.</p>
<p>On Windows, arguments that contain spaces are wrapped in quotes.</p>
<p>If the process cannot be started, -2 is returned. If the process crashes, -1 is returned. Otherwise, the process' exit code is returned.</p>
<!-- @@@execute -->
<!-- $$$execute$$$executeconstQString& -->
<h3 class="fn"><a name="execute-2"></a><span class="type">int</span> QProcess::<span class="name">execute</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i> )<tt> [static]</tt></h3>
<p>This is an overloaded function.</p>
<p>Starts the program <i>program</i> in a new process. <i>program</i> is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces.</p>
<!-- @@@execute -->
<!-- $$$exitCode[overload1]$$$exitCode -->
<h3 class="fn"><a name="exitCode"></a><span class="type">int</span> QProcess::<span class="name">exitCode</span> () const</h3>
<p>Returns the exit code of the last process that finished.</p>
<!-- @@@exitCode -->
<!-- $$$exitStatus[overload1]$$$exitStatus -->
<h3 class="fn"><a name="exitStatus"></a><span class="type"><a href="qprocess.html#ExitStatus-enum">QProcess::ExitStatus</a></span> QProcess::<span class="name">exitStatus</span> () const</h3>
<p>Returns the exit status of the last process that finished.</p>
<p>On Windows, if the process was terminated with TerminateProcess() from another application this function will still return <a href="qprocess.html#ExitStatus-enum">NormalExit</a> unless the exit code is less than 0.</p>
<p>This function was introduced in Qt 4.1.</p>
<!-- @@@exitStatus -->
<!-- $$$finished[overload1]$$$finishedintQProcess::ExitStatus -->
<h3 class="fn"><a name="finished"></a><span class="type">void</span> QProcess::<span class="name">finished</span> ( <span class="type">int</span> <i>exitCode</i>, <span class="type"><a href="qprocess.html#ExitStatus-enum">QProcess::ExitStatus</a></span> <i>exitStatus</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted when the process finishes. <i>exitCode</i> is the exit code of the process, and <i>exitStatus</i> is the exit status. After the process has finished, the buffers in <a href="qprocess.html">QProcess</a> are still intact. You can still read any data that the process may have written before it finished.</p>
<p><b>See also </b><a href="qprocess.html#exitStatus">exitStatus</a>().</p>
<!-- @@@finished -->
<!-- $$$isSequential[overload1]$$$isSequential -->
<h3 class="fn"><a name="isSequential"></a><span class="type">bool</span> QProcess::<span class="name">isSequential</span> () const<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#isSequential">QIODevice::isSequential</a>().</p>
<!-- @@@isSequential -->
<!-- $$$kill[overload1]$$$kill -->
<h3 class="fn"><a name="kill"></a><span class="type">void</span> QProcess::<span class="name">kill</span> ()<tt> [slot]</tt></h3>
<p>Kills the current process, causing it to exit immediately.</p>
<p>On Windows, kill() uses TerminateProcess, and on Unix and Mac OS X, the SIGKILL signal is sent to the process.</p>
<p>On Symbian, this function requires platform security capability <tt>PowerMgmt</tt>. If absent, the process will panic with KERN-EXEC 46.</p>
<p><b>Note:</b> Killing running processes from other processes will typically cause a panic in Symbian due to platform security.</p>
<p><b>See also </b><a href="symbian-platform-security-requirements.html">Symbian Platform Security Requirements</a> and <a href="qprocess.html#terminate">terminate</a>().</p>
<!-- @@@kill -->
<!-- $$$nativeArguments[overload1]$$$nativeArguments -->
<h3 class="fn"><a name="nativeArguments"></a><span class="type"><a href="qstring.html">QString</a></span> QProcess::<span class="name">nativeArguments</span> () const</h3>
<p>Returns the additional native command line arguments for the program.</p>
<p><b>Note:</b> This function is available only on the Windows and Symbian platforms.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also </b><a href="qprocess.html#setNativeArguments">setNativeArguments</a>().</p>
<!-- @@@nativeArguments -->
<!-- $$$pid[overload1]$$$pid -->
<h3 class="fn"><a name="pid"></a><span class="type"><a href="qprocess.html#Q_PID-typedef">Q_PID</a></span> QProcess::<span class="name">pid</span> () const</h3>
<p>Returns the native process identifier for the running process, if available. If no process is currently running, 0 is returned.</p>
<!-- @@@pid -->
<!-- $$$processChannelMode[overload1]$$$processChannelMode -->
<h3 class="fn"><a name="processChannelMode"></a><span class="type"><a href="qprocess.html#ProcessChannelMode-enum">ProcessChannelMode</a></span> QProcess::<span class="name">processChannelMode</span> () const</h3>
<p>Returns the channel mode of the <a href="qprocess.html">QProcess</a> standard output and standard error channels.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qprocess.html#setProcessChannelMode">setProcessChannelMode</a>(), <a href="qprocess.html#ProcessChannelMode-enum">ProcessChannelMode</a>, and <a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@processChannelMode -->
<!-- $$$processEnvironment[overload1]$$$processEnvironment -->
<h3 class="fn"><a name="processEnvironment"></a><span class="type"><a href="qprocessenvironment.html">QProcessEnvironment</a></span> QProcess::<span class="name">processEnvironment</span> () const</h3>
<p>Returns the environment that <a href="qprocess.html">QProcess</a> will use when starting a process, or an empty object if no environment has been set using <a href="qprocess.html#setEnvironment">setEnvironment</a>() or <a href="qprocess.html#setProcessEnvironment">setProcessEnvironment</a>(). If no environment has been set, the environment of the calling process will be used.</p>
<p><b>Note:</b> The environment settings are ignored on Windows CE, as there is no concept of an environment.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also </b><a href="qprocess.html#setProcessEnvironment">setProcessEnvironment</a>(), <a href="qprocess.html#setEnvironment">setEnvironment</a>(), and <a href="qprocessenvironment.html#isEmpty">QProcessEnvironment::isEmpty</a>().</p>
<!-- @@@processEnvironment -->
<!-- $$$readAllStandardError[overload1]$$$readAllStandardError -->
<h3 class="fn"><a name="readAllStandardError"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QProcess::<span class="name">readAllStandardError</span> ()</h3>
<p>Regardless of the current read channel, this function returns all data available from the standard error of the process as a <a href="qbytearray.html">QByteArray</a>.</p>
<p><b>See also </b><a href="qprocess.html#readyReadStandardError">readyReadStandardError</a>(), <a href="qprocess.html#readAllStandardOutput">readAllStandardOutput</a>(), <a href="qprocess.html#readChannel">readChannel</a>(), and <a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@readAllStandardError -->
<!-- $$$readAllStandardOutput[overload1]$$$readAllStandardOutput -->
<h3 class="fn"><a name="readAllStandardOutput"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QProcess::<span class="name">readAllStandardOutput</span> ()</h3>
<p>Regardless of the current read channel, this function returns all data available from the standard output of the process as a <a href="qbytearray.html">QByteArray</a>.</p>
<p><b>See also </b><a href="qprocess.html#readyReadStandardOutput">readyReadStandardOutput</a>(), <a href="qprocess.html#readAllStandardError">readAllStandardError</a>(), <a href="qprocess.html#readChannel">readChannel</a>(), and <a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@readAllStandardOutput -->
<!-- $$$readChannel[overload1]$$$readChannel -->
<h3 class="fn"><a name="readChannel"></a><span class="type"><a href="qprocess.html#ProcessChannel-enum">ProcessChannel</a></span> QProcess::<span class="name">readChannel</span> () const</h3>
<p>Returns the current read channel of the <a href="qprocess.html">QProcess</a>.</p>
<p><b>See also </b><a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@readChannel -->
<!-- $$$readData[overload1]$$$readDatachar*qint64 -->
<h3 class="fn"><a name="readData"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QProcess::<span class="name">readData</span> ( <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>maxlen</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#readData">QIODevice::readData</a>().</p>
<!-- @@@readData -->
<!-- $$$readyReadStandardError[overload1]$$$readyReadStandardError -->
<h3 class="fn"><a name="readyReadStandardError"></a><span class="type">void</span> QProcess::<span class="name">readyReadStandardError</span> ()<tt> [signal]</tt></h3>
<p>This signal is emitted when the process has made new data available through its standard error channel (<tt>stderr</tt>). It is emitted regardless of the current <a href="qprocess.html#readChannel">read channel</a>.</p>
<p><b>See also </b><a href="qprocess.html#readAllStandardError">readAllStandardError</a>() and <a href="qprocess.html#readChannel">readChannel</a>().</p>
<!-- @@@readyReadStandardError -->
<!-- $$$readyReadStandardOutput[overload1]$$$readyReadStandardOutput -->
<h3 class="fn"><a name="readyReadStandardOutput"></a><span class="type">void</span> QProcess::<span class="name">readyReadStandardOutput</span> ()<tt> [signal]</tt></h3>
<p>This signal is emitted when the process has made new data available through its standard output channel (<tt>stdout</tt>). It is emitted regardless of the current <a href="qprocess.html#readChannel">read channel</a>.</p>
<p><b>See also </b><a href="qprocess.html#readAllStandardOutput">readAllStandardOutput</a>() and <a href="qprocess.html#readChannel">readChannel</a>().</p>
<!-- @@@readyReadStandardOutput -->
<!-- $$$setEnvironment[overload1]$$$setEnvironmentconstQStringList& -->
<h3 class="fn"><a name="setEnvironment"></a><span class="type">void</span> QProcess::<span class="name">setEnvironment</span> ( const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp; <i>environment</i> )</h3>
<p>This function is deprecated.</p>
<p>Sets the environment that <a href="qprocess.html">QProcess</a> will use when starting a process to the <i>environment</i> specified which consists of a list of key=value pairs.</p>
<p>For example, the following code adds the <tt>C:\\BIN</tt> directory to the list of executable paths (<tt>PATHS</tt>) on Windows:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> process;
 <span class="type"><a href="qstringlist.html">QStringList</a></span> env <span class="operator">=</span> <span class="type"><a href="qprocess.html">QProcess</a></span><span class="operator">::</span>systemEnvironment();
 env <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;TMPDIR=C:\\MyApp\\temp&quot;</span>; <span class="comment">// Add an environment variable</span>
 env<span class="operator">.</span>replaceInStrings(<span class="type"><a href="qregexp.html">QRegExp</a></span>(<span class="string">&quot;^PATH=(.*)&quot;</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">::</span>CaseInsensitive)<span class="operator">,</span> <span class="string">&quot;PATH=\\1;C:\\Bin&quot;</span>);
 process<span class="operator">.</span>setEnvironment(env);
 process<span class="operator">.</span>start(<span class="string">&quot;myapp&quot;</span>);</pre>
<p><b>Note:</b> This function is less efficient than the <a href="qprocess.html#setProcessEnvironment">setProcessEnvironment</a>() function.</p>
<p><b>See also </b><a href="qprocess.html#environment">environment</a>(), <a href="qprocess.html#setProcessEnvironment">setProcessEnvironment</a>(), and <a href="qprocess.html#systemEnvironment">systemEnvironment</a>().</p>
<!-- @@@setEnvironment -->
<!-- $$$setNativeArguments[overload1]$$$setNativeArgumentsconstQString& -->
<h3 class="fn"><a name="setNativeArguments"></a><span class="type">void</span> QProcess::<span class="name">setNativeArguments</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>arguments</i> )</h3>
<p>This is an overloaded function.</p>
<p>Sets additional native command line <i>arguments</i> for the program.</p>
<p>On operating systems where the system API for passing command line <i>arguments</i> to a subprocess natively uses a single string, one can conceive command lines which cannot be passed via <a href="qprocess.html">QProcess</a>'s portable list-based API. In such cases this function must be used to set a string which is <i>appended</i> to the string composed from the usual argument list, with a delimiting space.</p>
<p><b>Note:</b> This function is available only on the Windows and Symbian platforms.</p>
<p>This function was introduced in Qt 4.7.</p>
<p><b>See also </b><a href="qprocess.html#nativeArguments">nativeArguments</a>().</p>
<!-- @@@setNativeArguments -->
<!-- $$$setProcessChannelMode[overload1]$$$setProcessChannelModeProcessChannelMode -->
<h3 class="fn"><a name="setProcessChannelMode"></a><span class="type">void</span> QProcess::<span class="name">setProcessChannelMode</span> ( <span class="type"><a href="qprocess.html#ProcessChannelMode-enum">ProcessChannelMode</a></span> <i>mode</i> )</h3>
<p>Sets the channel mode of the <a href="qprocess.html">QProcess</a> standard output and standard error channels to the <i>mode</i> specified. This mode will be used the next time <a href="qprocess.html#start">start</a>() is called. For example:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> builder;
 builder<span class="operator">.</span>setProcessChannelMode(<span class="type"><a href="qprocess.html">QProcess</a></span><span class="operator">::</span>MergedChannels);
 builder<span class="operator">.</span>start(<span class="string">&quot;make&quot;</span><span class="operator">,</span> <span class="type"><a href="qstringlist.html">QStringList</a></span>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;-j2&quot;</span>);

 <span class="keyword">if</span> (<span class="operator">!</span>builder<span class="operator">.</span>waitForFinished())
     <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Make failed:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> builder<span class="operator">.</span>errorString();
 <span class="keyword">else</span>
     <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Make output:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> builder<span class="operator">.</span>readAll();</pre>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qprocess.html#processChannelMode">processChannelMode</a>(), <a href="qprocess.html#ProcessChannelMode-enum">ProcessChannelMode</a>, and <a href="qprocess.html#setReadChannel">setReadChannel</a>().</p>
<!-- @@@setProcessChannelMode -->
<!-- $$$setProcessEnvironment[overload1]$$$setProcessEnvironmentconstQProcessEnvironment& -->
<h3 class="fn"><a name="setProcessEnvironment"></a><span class="type">void</span> QProcess::<span class="name">setProcessEnvironment</span> ( const <span class="type"><a href="qprocessenvironment.html">QProcessEnvironment</a></span> &amp; <i>environment</i> )</h3>
<p>Sets the environment that <a href="qprocess.html">QProcess</a> will use when starting a process to the <i>environment</i> object.</p>
<p>For example, the following code adds the <tt>C:\\BIN</tt> directory to the list of executable paths (<tt>PATHS</tt>) on Windows and sets <tt>TMPDIR</tt>:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> process;
 <span class="type"><a href="qprocessenvironment.html">QProcessEnvironment</a></span> env <span class="operator">=</span> <span class="type"><a href="qprocessenvironment.html">QProcessEnvironment</a></span><span class="operator">::</span>systemEnvironment();
 env<span class="operator">.</span>insert(<span class="string">&quot;TMPDIR&quot;</span><span class="operator">,</span> <span class="string">&quot;C:\\MyApp\\temp&quot;</span>); <span class="comment">// Add an environment variable</span>
 env<span class="operator">.</span>insert(<span class="string">&quot;PATH&quot;</span><span class="operator">,</span> env<span class="operator">.</span>value(<span class="string">&quot;Path&quot;</span>) <span class="operator">+</span> <span class="string">&quot;;C:\\Bin&quot;</span>);
 process<span class="operator">.</span>setProcessEnvironment(env);
 process<span class="operator">.</span>start(<span class="string">&quot;myapp&quot;</span>);</pre>
<p>Note how, on Windows, environment variable names are case-insensitive.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also </b><a href="qprocess.html#processEnvironment">processEnvironment</a>(), <a href="qprocessenvironment.html#systemEnvironment">QProcessEnvironment::systemEnvironment</a>(), and <a href="qprocess.html#setEnvironment">setEnvironment</a>().</p>
<!-- @@@setProcessEnvironment -->
<!-- $$$setProcessState[overload1]$$$setProcessStateProcessState -->
<h3 class="fn"><a name="setProcessState"></a><span class="type">void</span> QProcess::<span class="name">setProcessState</span> ( <span class="type"><a href="qprocess.html#ProcessState-enum">ProcessState</a></span> <i>state</i> )<tt> [protected]</tt></h3>
<p>Sets the current state of the <a href="qprocess.html">QProcess</a> to the <i>state</i> specified.</p>
<p><b>See also </b><a href="qprocess.html#state">state</a>().</p>
<!-- @@@setProcessState -->
<!-- $$$setReadChannel[overload1]$$$setReadChannelProcessChannel -->
<h3 class="fn"><a name="setReadChannel"></a><span class="type">void</span> QProcess::<span class="name">setReadChannel</span> ( <span class="type"><a href="qprocess.html#ProcessChannel-enum">ProcessChannel</a></span> <i>channel</i> )</h3>
<p>Sets the current read channel of the <a href="qprocess.html">QProcess</a> to the given <i>channel</i>. The current input channel is used by the functions <a href="qiodevice.html#read">read</a>(), <a href="qiodevice.html#readAll">readAll</a>(), <a href="qiodevice.html#readLine">readLine</a>(), and <a href="qiodevice.html#getChar">getChar</a>(). It also determines which channel triggers <a href="qprocess.html">QProcess</a> to emit <a href="qiodevice.html#readyRead">readyRead</a>().</p>
<p><b>See also </b><a href="qprocess.html#readChannel">readChannel</a>().</p>
<!-- @@@setReadChannel -->
<!-- $$$setStandardErrorFile[overload1]$$$setStandardErrorFileconstQString&OpenMode -->
<h3 class="fn"><a name="setStandardErrorFile"></a><span class="type">void</span> QProcess::<span class="name">setStandardErrorFile</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>fileName</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> = Truncate )</h3>
<p>Redirects the process' standard error to the file <i>fileName</i>. When the redirection is in place, the standard error read channel is closed: reading from it using <a href="qiodevice.html#read">read</a>() will always fail, as will <a href="qprocess.html#readAllStandardError">readAllStandardError</a>(). The file will be appended to if <i>mode</i> is Append, otherwise, it will be truncated.</p>
<p>See <a href="qprocess.html#setStandardOutputFile">setStandardOutputFile</a>() for more information on how the file is opened.</p>
<p>Note: if <a href="qprocess.html#setProcessChannelMode">setProcessChannelMode</a>() was called with an argument of <a href="qprocess.html#ProcessChannelMode-enum">QProcess::MergedChannels</a>, this function has no effect.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qprocess.html#setStandardInputFile">setStandardInputFile</a>(), <a href="qprocess.html#setStandardOutputFile">setStandardOutputFile</a>(), and <a href="qprocess.html#setStandardOutputProcess">setStandardOutputProcess</a>().</p>
<!-- @@@setStandardErrorFile -->
<!-- $$$setStandardInputFile[overload1]$$$setStandardInputFileconstQString& -->
<h3 class="fn"><a name="setStandardInputFile"></a><span class="type">void</span> QProcess::<span class="name">setStandardInputFile</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>fileName</i> )</h3>
<p>Redirects the process' standard input to the file indicated by <i>fileName</i>. When an input redirection is in place, the <a href="qprocess.html">QProcess</a> object will be in read-only mode (calling <a href="qiodevice.html#write">write</a>() will result in error).</p>
<p>If the file <i>fileName</i> does not exist at the moment <a href="qprocess.html#start">start</a>() is called or is not readable, starting the process will fail.</p>
<p>Calling setStandardInputFile() after the process has started has no effect.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qprocess.html#setStandardOutputFile">setStandardOutputFile</a>(), <a href="qprocess.html#setStandardErrorFile">setStandardErrorFile</a>(), and <a href="qprocess.html#setStandardOutputProcess">setStandardOutputProcess</a>().</p>
<!-- @@@setStandardInputFile -->
<!-- $$$setStandardOutputFile[overload1]$$$setStandardOutputFileconstQString&OpenMode -->
<h3 class="fn"><a name="setStandardOutputFile"></a><span class="type">void</span> QProcess::<span class="name">setStandardOutputFile</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>fileName</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> = Truncate )</h3>
<p>Redirects the process' standard output to the file <i>fileName</i>. When the redirection is in place, the standard output read channel is closed: reading from it using <a href="qiodevice.html#read">read</a>() will always fail, as will <a href="qprocess.html#readAllStandardOutput">readAllStandardOutput</a>().</p>
<p>If the file <i>fileName</i> doesn't exist at the moment <a href="qprocess.html#start">start</a>() is called, it will be created. If it cannot be created, the starting will fail.</p>
<p>If the file exists and <i>mode</i> is <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::Truncate</a>, the file will be truncated. Otherwise (if <i>mode</i> is <a href="qiodevice.html#OpenModeFlag-enum">QIODevice::Append</a>), the file will be appended to.</p>
<p>Calling setStandardOutputFile() after the process has started has no effect.</p>
<p>This function was introduced in Qt 4.2.</p>
<p><b>See also </b><a href="qprocess.html#setStandardInputFile">setStandardInputFile</a>(), <a href="qprocess.html#setStandardErrorFile">setStandardErrorFile</a>(), and <a href="qprocess.html#setStandardOutputProcess">setStandardOutputProcess</a>().</p>
<!-- @@@setStandardOutputFile -->
<!-- $$$setStandardOutputProcess[overload1]$$$setStandardOutputProcessQProcess* -->
<h3 class="fn"><a name="setStandardOutputProcess"></a><span class="type">void</span> QProcess::<span class="name">setStandardOutputProcess</span> ( <span class="type">QProcess</span> * <i>destination</i> )</h3>
<p>Pipes the standard output stream of this process to the <i>destination</i> process' standard input.</p>
<p>The following shell command:</p>
<pre class="cpp"> command1 <span class="operator">|</span> command2</pre>
<p>Can be accomplished with QProcesses with the following code:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> process1;
 <span class="type"><a href="qprocess.html">QProcess</a></span> process2;

 process1<span class="operator">.</span>setStandardOutputProcess(<span class="operator">&amp;</span>process2);

 process1<span class="operator">.</span>start(<span class="string">&quot;command1&quot;</span>);
 process2<span class="operator">.</span>start(<span class="string">&quot;command2&quot;</span>);</pre>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@setStandardOutputProcess -->
<!-- $$$setWorkingDirectory[overload1]$$$setWorkingDirectoryconstQString& -->
<h3 class="fn"><a name="setWorkingDirectory"></a><span class="type">void</span> QProcess::<span class="name">setWorkingDirectory</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>dir</i> )</h3>
<p>Sets the working directory to <i>dir</i>. <a href="qprocess.html">QProcess</a> will start the process in this directory. The default behavior is to start the process in the working directory of the calling process.</p>
<p><b>Note:</b> The working directory setting is ignored on Symbian; the private directory of the process is considered its working directory.</p>
<p><b>Note:</b> On QNX, this may cause all application threads to temporarily freeze.</p>
<p><b>See also </b><a href="qprocess.html#workingDirectory">workingDirectory</a>() and <a href="qprocess.html#start">start</a>().</p>
<!-- @@@setWorkingDirectory -->
<!-- $$$setupChildProcess[overload1]$$$setupChildProcess -->
<h3 class="fn"><a name="setupChildProcess"></a><span class="type">void</span> QProcess::<span class="name">setupChildProcess</span> ()<tt> [virtual protected]</tt></h3>
<p>This function is called in the child process context just before the program is executed on Unix or Mac OS X (i.e&#x2e;, after <i>fork()</i>, but before <i>execve()</i>). Reimplement this function to do last minute initialization of the child process. Example:</p>
<pre class="cpp"> <span class="keyword">class</span> SandboxProcess : <span class="keyword">public</span> <span class="type"><a href="qprocess.html">QProcess</a></span>
 {
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  <span class="keyword">protected</span>:
      <span class="type">void</span> setupChildProcess();
     <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
 };

 <span class="type">void</span> SandboxProcess<span class="operator">::</span>setupChildProcess()
 {
     <span class="comment">// Drop all privileges in the child process, and enter</span>
     <span class="comment">// a chroot jail.</span>
 <span class="preprocessor">#if defined Q_OS_UNIX</span>
     <span class="operator">::</span>setgroups(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);
     <span class="operator">::</span>chroot(<span class="string">&quot;/etc/safe&quot;</span>);
     <span class="operator">::</span>chdir(<span class="string">&quot;/&quot;</span>);
     <span class="operator">::</span>setgid(safeGid);
     <span class="operator">::</span>setuid(safeUid);
     <span class="operator">::</span>umask(<span class="number">0</span>);
 <span class="preprocessor">#endif</span>
 }</pre>
<p>You cannot exit the process (by calling exit(), for instance) from this function. If you need to stop the program before it starts execution, your workaround is to emit <a href="qprocess.html#finished">finished</a>() and then call exit().</p>
<p><b>Warning:</b> This function is called by <a href="qprocess.html">QProcess</a> on Unix and Mac OS X only. On Windows and QNX, it is not called.</p>
<!-- @@@setupChildProcess -->
<!-- $$$start[overload1]$$$startconstQString&constQStringList&OpenMode -->
<h3 class="fn"><a name="start"></a><span class="type">void</span> QProcess::<span class="name">start</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i>, const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp; <i>arguments</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> = ReadWrite )</h3>
<p>Starts the given <i>program</i> in a new process, if none is already running, passing the command line arguments in <i>arguments</i>. The <a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a> is set to <i>mode</i>.</p>
<p>The <a href="qprocess.html">QProcess</a> object will immediately enter the Starting state. If the process starts successfully, <a href="qprocess.html">QProcess</a> will emit <a href="qprocess.html#started">started</a>(); otherwise, <a href="qprocess.html#error">error</a>() will be emitted. If the <a href="qprocess.html">QProcess</a> object is already running a process, a warning may be printed at the console, and the existing process will continue running.</p>
<p><b>Note:</b> Processes are started asynchronously, which means the <a href="qprocess.html#started">started</a>() and <a href="qprocess.html#error">error</a>() signals may be delayed. Call <a href="qprocess.html#waitForStarted">waitForStarted</a>() to make sure the process has started (or has failed to start) and those signals have been emitted.</p>
<p><b>Note:</b> No further splitting of the arguments is performed.</p>
<p><b>Windows:</b> Arguments that contain spaces are wrapped in quotes.</p>
<p><b>See also </b><a href="qprocess.html#pid">pid</a>(), <a href="qprocess.html#started">started</a>(), and <a href="qprocess.html#waitForStarted">waitForStarted</a>().</p>
<!-- @@@start -->
<!-- $$$start$$$startconstQString&OpenMode -->
<h3 class="fn"><a name="start-2"></a><span class="type">void</span> QProcess::<span class="name">start</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i>, <span class="type"><a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a></span> <i>mode</i> = ReadWrite )</h3>
<p>This is an overloaded function.</p>
<p>Starts the program <i>program</i> in a new process, if one is not already running. <i>program</i> is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces. For example:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> process;
 process<span class="operator">.</span>start(<span class="string">&quot;del /s *.txt&quot;</span>);
 <span class="comment">// same as process.start(&quot;del&quot;, QStringList() &lt;&lt; &quot;/s&quot; &lt;&lt; &quot;*.txt&quot;);</span>
 <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span></pre>
<p>The <i>program</i> string can also contain quotes, to ensure that arguments containing spaces are correctly supplied to the new process. For example:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> process;
 process<span class="operator">.</span>start(<span class="string">&quot;dir \&quot;My Documents\&quot;&quot;</span>);</pre>
<p>If the <a href="qprocess.html">QProcess</a> object is already running a process, a warning may be printed at the console, and the existing process will continue running.</p>
<p>Note that, on Windows, quotes need to be both escaped and quoted. For example, the above code would be specified in the following way to ensure that <tt>&quot;My Documents&quot;</tt> is used as the argument to the <tt>dir</tt> executable:</p>
<pre class="cpp"> <span class="type"><a href="qprocess.html">QProcess</a></span> process;
 process<span class="operator">.</span>start(<span class="string">&quot;dir \&quot;\&quot;\&quot;My Documents\&quot;\&quot;\&quot;&quot;</span>);</pre>
<p>The <a href="qiodevice.html#OpenModeFlag-enum">OpenMode</a> is set to <i>mode</i>.</p>
<!-- @@@start -->
<!-- $$$startDetached[overload1]$$$startDetachedconstQString&constQStringList&constQString&qint64* -->
<h3 class="fn"><a name="startDetached"></a><span class="type">bool</span> QProcess::<span class="name">startDetached</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i>, const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp; <i>arguments</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>workingDirectory</i>, <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> * <i>pid</i> = 0 )<tt> [static]</tt></h3>
<p>Starts the program <i>program</i> with the arguments <i>arguments</i> in a new process, and detaches from it. Returns true on success; otherwise returns false. If the calling process exits, the detached process will continue to live.</p>
<p>Note that arguments that contain spaces are not passed to the process as separate arguments.</p>
<p><b>Unix:</b> The started process will run in its own session and act like a daemon.</p>
<p><b>Windows:</b> Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process.</p>
<p>The process will be started in the directory <i>workingDirectory</i>.</p>
<p><b>Note:</b> On QNX, this may cause all application threads to temporarily freeze.</p>
<p>If the function is successful then *<i>pid</i> is set to the process identifier of the started process.</p>
<!-- @@@startDetached -->
<!-- $$$startDetached$$$startDetachedconstQString&constQStringList& -->
<h3 class="fn"><a name="startDetached-2"></a><span class="type">bool</span> QProcess::<span class="name">startDetached</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i>, const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp; <i>arguments</i> )<tt> [static]</tt></h3>
<p>Starts the program <i>program</i> with the given <i>arguments</i> in a new process, and detaches from it. Returns true on success; otherwise returns false. If the calling process exits, the detached process will continue to live.</p>
<p><b>Note:</b> Arguments that contain spaces are not passed to the process as separate arguments.</p>
<p><b>Unix:</b> The started process will run in its own session and act like a daemon.</p>
<p><b>Windows:</b> Arguments that contain spaces are wrapped in quotes. The started process will run as a regular standalone process.</p>
<!-- @@@startDetached -->
<!-- $$$startDetached$$$startDetachedconstQString& -->
<h3 class="fn"><a name="startDetached-3"></a><span class="type">bool</span> QProcess::<span class="name">startDetached</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>program</i> )<tt> [static]</tt></h3>
<p>This is an overloaded function.</p>
<p>Starts the program <i>program</i> in a new process. <i>program</i> is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces.</p>
<p>The <i>program</i> string can also contain quotes, to ensure that arguments containing spaces are correctly supplied to the new process.</p>
<!-- @@@startDetached -->
<!-- $$$started[overload1]$$$started -->
<h3 class="fn"><a name="started"></a><span class="type">void</span> QProcess::<span class="name">started</span> ()<tt> [signal]</tt></h3>
<p>This signal is emitted by <a href="qprocess.html">QProcess</a> when the process has started, and <a href="qprocess.html#state">state</a>() returns <a href="qprocess.html#ProcessState-enum">Running</a>.</p>
<!-- @@@started -->
<!-- $$$state[overload1]$$$state -->
<h3 class="fn"><a name="state"></a><span class="type"><a href="qprocess.html#ProcessState-enum">QProcess::ProcessState</a></span> QProcess::<span class="name">state</span> () const</h3>
<p>Returns the current state of the process.</p>
<p><b>See also </b><a href="qprocess.html#stateChanged">stateChanged</a>() and <a href="qprocess.html#error">error</a>().</p>
<!-- @@@state -->
<!-- $$$stateChanged[overload1]$$$stateChangedQProcess::ProcessState -->
<h3 class="fn"><a name="stateChanged"></a><span class="type">void</span> QProcess::<span class="name">stateChanged</span> ( <span class="type"><a href="qprocess.html#ProcessState-enum">QProcess::ProcessState</a></span> <i>newState</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted whenever the state of <a href="qprocess.html">QProcess</a> changes. The <i>newState</i> argument is the state <a href="qprocess.html">QProcess</a> changed to.</p>
<!-- @@@stateChanged -->
<!-- $$$systemEnvironment[overload1]$$$systemEnvironment -->
<h3 class="fn"><a name="systemEnvironment"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QProcess::<span class="name">systemEnvironment</span> ()<tt> [static]</tt></h3>
<p>Returns the environment of the calling process as a list of key=value pairs. Example:</p>
<pre class="cpp"> <span class="type"><a href="qstringlist.html">QStringList</a></span> environment <span class="operator">=</span> <span class="type"><a href="qprocess.html">QProcess</a></span><span class="operator">::</span>systemEnvironment();
 <span class="comment">// environment = {&quot;PATH=/usr/bin:/usr/local/bin&quot;,</span>
 <span class="comment">//                &quot;USER=greg&quot;, &quot;HOME=/home/greg&quot;}</span></pre>
<p>This function does not cache the system environment. Therefore, it's possible to obtain an updated version of the environment if low-level C library functions like <tt>setenv</tt> ot <tt>putenv</tt> have been called.</p>
<p>However, note that repeated calls to this function will recreate the list of environment variables, which is a non-trivial operation.</p>
<p><b>Note:</b> For new code, it is recommended to use <a href="qprocessenvironment.html#systemEnvironment">QProcessEnvironment::systemEnvironment</a>()</p>
<p>This function was introduced in Qt 4.1.</p>
<p><b>See also </b><a href="qprocessenvironment.html#systemEnvironment">QProcessEnvironment::systemEnvironment</a>(), <a href="qprocess.html#environment">environment</a>(), and <a href="qprocess.html#setEnvironment">setEnvironment</a>().</p>
<!-- @@@systemEnvironment -->
<!-- $$$terminate[overload1]$$$terminate -->
<h3 class="fn"><a name="terminate"></a><span class="type">void</span> QProcess::<span class="name">terminate</span> ()<tt> [slot]</tt></h3>
<p>Attempts to terminate the process.</p>
<p>The process may not exit as a result of calling this function (it is given the chance to prompt the user for any unsaved files, etc).</p>
<p>On Windows, terminate() posts a WM_CLOSE message to all toplevel windows of the process and then to the main thread of the process itself. On Unix and Mac OS X the SIGTERM signal is sent.</p>
<p>Console applications on Windows that do not run an event loop, or whose event loop does not handle the WM_CLOSE message, can only be terminated by calling <a href="qprocess.html#kill">kill</a>().</p>
<p>On Symbian, this function requires platform security capability <tt>PowerMgmt</tt>. If absent, the process will panic with KERN-EXEC 46.</p>
<p><b>Note:</b> Terminating running processes from other processes will typically cause a panic in Symbian due to platform security.</p>
<p><b>See also </b><a href="symbian-platform-security-requirements.html">Symbian Platform Security Requirements</a> and <a href="qprocess.html#kill">kill</a>().</p>
<!-- @@@terminate -->
<!-- $$$waitForBytesWritten[overload1]$$$waitForBytesWrittenint -->
<h3 class="fn"><a name="waitForBytesWritten"></a><span class="type">bool</span> QProcess::<span class="name">waitForBytesWritten</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#waitForBytesWritten">QIODevice::waitForBytesWritten</a>().</p>
<!-- @@@waitForBytesWritten -->
<!-- $$$waitForFinished[overload1]$$$waitForFinishedint -->
<h3 class="fn"><a name="waitForFinished"></a><span class="type">bool</span> QProcess::<span class="name">waitForFinished</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )</h3>
<p>Blocks until the process has finished and the <a href="qprocess.html#finished">finished</a>() signal has been emitted, or until <i>msecs</i> milliseconds have passed.</p>
<p>Returns true if the process finished; otherwise returns false (if the operation timed out, if an error occurred, or if this <a href="qprocess.html">QProcess</a> is already finished).</p>
<p>This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.</p>
<p><b>Warning:</b> Calling this function from the main (GUI) thread might cause your user interface to freeze.</p>
<p>If msecs is -1, this function will not time out.</p>
<p><b>See also </b><a href="qprocess.html#finished">finished</a>(), <a href="qprocess.html#waitForStarted">waitForStarted</a>(), <a href="qprocess.html#waitForReadyRead">waitForReadyRead</a>(), and <a href="qprocess.html#waitForBytesWritten">waitForBytesWritten</a>().</p>
<!-- @@@waitForFinished -->
<!-- $$$waitForReadyRead[overload1]$$$waitForReadyReadint -->
<h3 class="fn"><a name="waitForReadyRead"></a><span class="type">bool</span> QProcess::<span class="name">waitForReadyRead</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#waitForReadyRead">QIODevice::waitForReadyRead</a>().</p>
<!-- @@@waitForReadyRead -->
<!-- $$$waitForStarted[overload1]$$$waitForStartedint -->
<h3 class="fn"><a name="waitForStarted"></a><span class="type">bool</span> QProcess::<span class="name">waitForStarted</span> ( <span class="type">int</span> <i>msecs</i> = 30000 )</h3>
<p>Blocks until the process has started and the <a href="qprocess.html#started">started</a>() signal has been emitted, or until <i>msecs</i> milliseconds have passed.</p>
<p>Returns true if the process was started successfully; otherwise returns false (if the operation timed out or if an error occurred).</p>
<p>This function can operate without an event loop. It is useful when writing non-GUI applications and when performing I/O operations in a non-GUI thread.</p>
<p><b>Warning:</b> Calling this function from the main (GUI) thread might cause your user interface to freeze.</p>
<p>If msecs is -1, this function will not time out.</p>
<p><b>See also </b><a href="qprocess.html#started">started</a>(), <a href="qprocess.html#waitForReadyRead">waitForReadyRead</a>(), <a href="qprocess.html#waitForBytesWritten">waitForBytesWritten</a>(), and <a href="qprocess.html#waitForFinished">waitForFinished</a>().</p>
<!-- @@@waitForStarted -->
<!-- $$$workingDirectory[overload1]$$$workingDirectory -->
<h3 class="fn"><a name="workingDirectory"></a><span class="type"><a href="qstring.html">QString</a></span> QProcess::<span class="name">workingDirectory</span> () const</h3>
<p>If <a href="qprocess.html">QProcess</a> has been assigned a working directory, this function returns the working directory that the <a href="qprocess.html">QProcess</a> will enter before the program has started. Otherwise, (i.e&#x2e;, no directory has been assigned,) an empty string is returned, and <a href="qprocess.html">QProcess</a> will use the application's current working directory instead.</p>
<p><b>See also </b><a href="qprocess.html#setWorkingDirectory">setWorkingDirectory</a>().</p>
<!-- @@@workingDirectory -->
<!-- $$$writeData[overload1]$$$writeDataconstchar*qint64 -->
<h3 class="fn"><a name="writeData"></a><span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> QProcess::<span class="name">writeData</span> ( const <span class="type">char</span> * <i>data</i>, <span class="type"><a href="qtglobal.html#qint64-typedef">qint64</a></span> <i>len</i> )<tt> [virtual protected]</tt></h3>
<p>Reimplemented from <a href="qiodevice.html#writeData">QIODevice::writeData</a>().</p>
<!-- @@@writeData -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$Q_PID -->
<h3 class="fn"><a name="Q_PID-typedef"></a>typedef <span class="name">Q_PID</span></h3>
<p>Typedef for the identifiers used to represent processes on the underlying platform. On Unix and Symbian, this corresponds to <a href="qtglobal.html#qint64-typedef">qint64</a>; on Windows, it corresponds to <tt>_PROCESS_INFORMATION*</tt>.</p>
<p><b>See also </b><a href="qprocess.html#pid">QProcess::pid</a>().</p>
<!-- @@@Q_PID -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Qt and respective logos are trademarks of The Qt Company Ltd 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>