| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qprocess.cpp:52 -->
|
|---|
| 3 | <html>
|
|---|
| 4 | <head>
|
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|---|
| 6 | <title>QProcess Class</title>
|
|---|
| 7 | <style type="text/css"><!--
|
|---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
|---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
|---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
|---|
| 11 | body { background: #ffffff; color: black; }
|
|---|
| 12 | --></style>
|
|---|
| 13 | </head>
|
|---|
| 14 | <body>
|
|---|
| 15 |
|
|---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
|---|
| 17 | <tr bgcolor="#E5E5E5">
|
|---|
| 18 | <td valign=center>
|
|---|
| 19 | <a href="index.html">
|
|---|
| 20 | <font color="#004faf">Home</font></a>
|
|---|
| 21 | | <a href="classes.html">
|
|---|
| 22 | <font color="#004faf">All Classes</font></a>
|
|---|
| 23 | | <a href="mainclasses.html">
|
|---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
|---|
| 25 | | <a href="annotated.html">
|
|---|
| 26 | <font color="#004faf">Annotated</font></a>
|
|---|
| 27 | | <a href="groups.html">
|
|---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
|---|
| 29 | | <a href="functions.html">
|
|---|
| 30 | <font color="#004faf">Functions</font></a>
|
|---|
| 31 | </td>
|
|---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QProcess Class Reference</h1>
|
|---|
| 33 |
|
|---|
| 34 | <p>The QProcess class is used to start external programs and
|
|---|
| 35 | to communicate with them.
|
|---|
| 36 | <a href="#details">More...</a>
|
|---|
| 37 | <p><tt>#include <<a href="qprocess-h.html">qprocess.h</a>></tt>
|
|---|
| 38 | <p>Inherits <a href="qobject.html">QObject</a>.
|
|---|
| 39 | <p><a href="qprocess-members.html">List of all member functions.</a>
|
|---|
| 40 | <h2>Public Members</h2>
|
|---|
| 41 | <ul>
|
|---|
| 42 | <li class=fn><a href="#QProcess"><b>QProcess</b></a> ( QObject * parent = 0, const char * name = 0 )</li>
|
|---|
| 43 | <li class=fn><a href="#QProcess-2"><b>QProcess</b></a> ( const QString & arg0, QObject * parent = 0, const char * name = 0 )</li>
|
|---|
| 44 | <li class=fn><a href="#QProcess-3"><b>QProcess</b></a> ( const QStringList & args, QObject * parent = 0, const char * name = 0 )</li>
|
|---|
| 45 | <li class=fn><a href="#~QProcess"><b>~QProcess</b></a> ()</li>
|
|---|
| 46 | <li class=fn>QStringList <a href="#arguments"><b>arguments</b></a> () const</li>
|
|---|
| 47 | <li class=fn>void <a href="#clearArguments"><b>clearArguments</b></a> ()</li>
|
|---|
| 48 | <li class=fn>virtual void <a href="#setArguments"><b>setArguments</b></a> ( const QStringList & args )</li>
|
|---|
| 49 | <li class=fn>virtual void <a href="#addArgument"><b>addArgument</b></a> ( const QString & arg )</li>
|
|---|
| 50 | <li class=fn>QDir <a href="#workingDirectory"><b>workingDirectory</b></a> () const</li>
|
|---|
| 51 | <li class=fn>virtual void <a href="#setWorkingDirectory"><b>setWorkingDirectory</b></a> ( const QDir & dir )</li>
|
|---|
| 52 | <li class=fn>enum <a href="#Communication-enum"><b>Communication</b></a> { Stdin = 0x01, Stdout = 0x02, Stderr = 0x04, DupStderr = 0x08 }</li>
|
|---|
| 53 | <li class=fn>void <a href="#setCommunication"><b>setCommunication</b></a> ( int commFlags )</li>
|
|---|
| 54 | <li class=fn>int <a href="#communication"><b>communication</b></a> () const</li>
|
|---|
| 55 | <li class=fn>virtual bool <a href="#start"><b>start</b></a> ( QStringList * env = 0 )</li>
|
|---|
| 56 | <li class=fn>virtual bool <a href="#launch-2"><b>launch</b></a> ( const QString & buf, QStringList * env = 0 )</li>
|
|---|
| 57 | <li class=fn>virtual bool <a href="#launch"><b>launch</b></a> ( const QByteArray & buf, QStringList * env = 0 )</li>
|
|---|
| 58 | <li class=fn>bool <a href="#isRunning"><b>isRunning</b></a> () const</li>
|
|---|
| 59 | <li class=fn>bool <a href="#normalExit"><b>normalExit</b></a> () const</li>
|
|---|
| 60 | <li class=fn>int <a href="#exitStatus"><b>exitStatus</b></a> () const</li>
|
|---|
| 61 | <li class=fn>virtual QByteArray <a href="#readStdout"><b>readStdout</b></a> ()</li>
|
|---|
| 62 | <li class=fn>virtual QByteArray <a href="#readStderr"><b>readStderr</b></a> ()</li>
|
|---|
| 63 | <li class=fn>bool <a href="#canReadLineStdout"><b>canReadLineStdout</b></a> () const</li>
|
|---|
| 64 | <li class=fn>bool <a href="#canReadLineStderr"><b>canReadLineStderr</b></a> () const</li>
|
|---|
| 65 | <li class=fn>virtual QString <a href="#readLineStdout"><b>readLineStdout</b></a> ()</li>
|
|---|
| 66 | <li class=fn>virtual QString <a href="#readLineStderr"><b>readLineStderr</b></a> ()</li>
|
|---|
| 67 | <li class=fn>PID <a href="#processIdentifier"><b>processIdentifier</b></a> ()</li>
|
|---|
| 68 | </ul>
|
|---|
| 69 | <h2>Public Slots</h2>
|
|---|
| 70 | <ul>
|
|---|
| 71 | <li class=fn>void <a href="#tryTerminate"><b>tryTerminate</b></a> () const</li>
|
|---|
| 72 | <li class=fn>void <a href="#kill"><b>kill</b></a> () const</li>
|
|---|
| 73 | <li class=fn>virtual void <a href="#writeToStdin"><b>writeToStdin</b></a> ( const QByteArray & buf )</li>
|
|---|
| 74 | <li class=fn>virtual void <a href="#writeToStdin-2"><b>writeToStdin</b></a> ( const QString & buf )</li>
|
|---|
| 75 | <li class=fn>virtual void <a href="#closeStdin"><b>closeStdin</b></a> ()</li>
|
|---|
| 76 | </ul>
|
|---|
| 77 | <h2>Signals</h2>
|
|---|
| 78 | <ul>
|
|---|
| 79 | <li class=fn>void <a href="#readyReadStdout"><b>readyReadStdout</b></a> ()</li>
|
|---|
| 80 | <li class=fn>void <a href="#readyReadStderr"><b>readyReadStderr</b></a> ()</li>
|
|---|
| 81 | <li class=fn>void <a href="#processExited"><b>processExited</b></a> ()</li>
|
|---|
| 82 | <li class=fn>void <a href="#wroteToStdin"><b>wroteToStdin</b></a> ()</li>
|
|---|
| 83 | <li class=fn>void <a href="#launchFinished"><b>launchFinished</b></a> ()</li>
|
|---|
| 84 | </ul>
|
|---|
| 85 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | <p> The QProcess class is used to start external programs and
|
|---|
| 89 | to communicate with them.
|
|---|
| 90 | <p>
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | <p> You can write to the started program's standard input, and can
|
|---|
| 94 | read the program's standard output and standard error. You can
|
|---|
| 95 | pass command line arguments to the program either in the
|
|---|
| 96 | constructor or with <a href="#setArguments">setArguments</a>() or <a href="#addArgument">addArgument</a>(). The program's
|
|---|
| 97 | working directory can be set with <a href="#setWorkingDirectory">setWorkingDirectory</a>(). If you
|
|---|
| 98 | need to set up environment variables pass them to the <a href="#start">start</a>() or
|
|---|
| 99 | <a href="#launch">launch</a>() functions (see below). The <a href="#processExited">processExited</a>() signal is
|
|---|
| 100 | emitted if the program exits. The program's exit status is
|
|---|
| 101 | available from <a href="#exitStatus">exitStatus</a>(), although you could simply call
|
|---|
| 102 | <a href="#normalExit">normalExit</a>() to see if the program terminated normally.
|
|---|
| 103 | <p> There are two different ways to start a process. If you just want
|
|---|
| 104 | to run a program, optionally passing data to its standard input at
|
|---|
| 105 | the beginning, use one of the launch() functions. If you want full
|
|---|
| 106 | control of the program's standard input (especially if you don't
|
|---|
| 107 | know all the data you want to send to standard input at the
|
|---|
| 108 | beginning), use the start() function.
|
|---|
| 109 | <p> If you use start() you can write to the program's standard input
|
|---|
| 110 | using <a href="#writeToStdin">writeToStdin</a>() and you can close the standard input with
|
|---|
| 111 | <a href="#closeStdin">closeStdin</a>(). The <a href="#wroteToStdin">wroteToStdin</a>() signal is emitted if the data
|
|---|
| 112 | sent to standard input has been written. You can read from the
|
|---|
| 113 | program's standard output using <a href="#readStdout">readStdout</a>() or <a href="#readLineStdout">readLineStdout</a>().
|
|---|
| 114 | These functions return an empty <a href="qbytearray.html">QByteArray</a> if there is no data to
|
|---|
| 115 | read. The <a href="#readyReadStdout">readyReadStdout</a>() signal is emitted when there is data
|
|---|
| 116 | available to be read from standard output. Standard error has a
|
|---|
| 117 | set of functions that correspond to the standard output functions,
|
|---|
| 118 | i.e. <a href="#readStderr">readStderr</a>(), <a href="#readLineStderr">readLineStderr</a>() and <a href="#readyReadStderr">readyReadStderr</a>().
|
|---|
| 119 | <p> If you use one of the <a href="#launch">launch</a>() functions the data you pass will be
|
|---|
| 120 | sent to the program's standard input which will be closed once all
|
|---|
| 121 | the data has been written. You should <em>not</em> use <a href="#writeToStdin">writeToStdin</a>() or
|
|---|
| 122 | <a href="#closeStdin">closeStdin</a>() if you use launch(). If you need to send data to the
|
|---|
| 123 | program's standard input after it has started running use <a href="#start">start</a>()
|
|---|
| 124 | instead of launch().
|
|---|
| 125 | <p> Both start() and launch() can accept a string list of strings each
|
|---|
| 126 | of which has the format, key=value, where the keys are the names
|
|---|
| 127 | of environment variables.
|
|---|
| 128 | <p> You can test to see if a program is running with <a href="#isRunning">isRunning</a>(). The
|
|---|
| 129 | program's process identifier is available from
|
|---|
| 130 | <a href="#processIdentifier">processIdentifier</a>(). If you want to terminate a running program
|
|---|
| 131 | use <a href="#tryTerminate">tryTerminate</a>(), but note that the program may ignore this. If
|
|---|
| 132 | you <em>really</em> want to terminate the program, without it having any
|
|---|
| 133 | chance to clean up, you can use <a href="#kill">kill</a>().
|
|---|
| 134 | <p> As an example, suppose we want to start the <tt>uic</tt> command (a Qt
|
|---|
| 135 | command line tool used with <em>Qt Designer</em>) and perform some
|
|---|
| 136 | operations on the output (the <tt>uic</tt> outputs the code it generates
|
|---|
| 137 | to standard output by default). Suppose further that we want to
|
|---|
| 138 | run the program on the file "small_dialog.ui" with the command
|
|---|
| 139 | line options "-tr <a href="i18n.html#i18n">i18n</a>". On the command line we would write:
|
|---|
| 140 | <pre>
|
|---|
| 141 | uic -tr i18n small_dialog.ui
|
|---|
| 142 | </pre>
|
|---|
| 143 |
|
|---|
| 144 | <p>
|
|---|
| 145 |
|
|---|
| 146 | <p> A code snippet for this with the QProcess class might look like
|
|---|
| 147 | this:
|
|---|
| 148 | <p> <pre> UicManager::UicManager()
|
|---|
| 149 | {
|
|---|
| 150 | </pre><pre> proc = new QProcess( this );
|
|---|
| 151 | </pre><pre> <a name="x2122"></a> proc-><a href="#addArgument">addArgument</a>( "uic" );
|
|---|
| 152 | proc-><a href="#addArgument">addArgument</a>( "-tr" );
|
|---|
| 153 | proc-><a href="#addArgument">addArgument</a>( "i18n" );
|
|---|
| 154 | proc-><a href="#addArgument">addArgument</a>( "small_dialog.ui" );
|
|---|
| 155 |
|
|---|
| 156 | <a name="x2123"></a> <a href="qobject.html#connect">connect</a>( proc, SIGNAL(<a href="#readyReadStdout">readyReadStdout</a>()),
|
|---|
| 157 | this, SLOT(readFromStdout()) );
|
|---|
| 158 | </pre><pre> <a name="x2124"></a> if ( !proc-><a href="#start">start</a>() ) {
|
|---|
| 159 | // error handling
|
|---|
| 160 | </pre><pre> }
|
|---|
| 161 | }
|
|---|
| 162 | </pre>
|
|---|
| 163 | <p> <pre> void UicManager::readFromStdout()
|
|---|
| 164 | {
|
|---|
| 165 | // Read and process the data.
|
|---|
| 166 | // Bear in mind that the data might be output in chunks.
|
|---|
| 167 | </pre><pre> }
|
|---|
| 168 | </pre>
|
|---|
| 169 | <p> Although you may need quotes for a file named on the command line
|
|---|
| 170 | (e.g. if it contains spaces) you shouldn't use extra quotes for
|
|---|
| 171 | arguments passed to <a href="#addArgument">addArgument</a>() or <a href="#setArguments">setArguments</a>().
|
|---|
| 172 | <p> The <a href="#readyReadStdout">readyReadStdout</a>() signal is emitted when there is new data on
|
|---|
| 173 | standard output. This happens asynchronously: you don't know if
|
|---|
| 174 | more data will arrive later.
|
|---|
| 175 | <p> In the above example you could connect the <a href="#processExited">processExited</a>() signal
|
|---|
| 176 | to the slot UicManager::readFromStdout() instead. If you do so,
|
|---|
| 177 | you will be certain that all the data is available when the slot
|
|---|
| 178 | is called. On the other hand, you must wait until the process has
|
|---|
| 179 | finished before doing any processing.
|
|---|
| 180 | <p> Note that if you are expecting a lot of output from the process,
|
|---|
| 181 | you may hit platform-dependent limits to the pipe buffer size. The
|
|---|
| 182 | solution is to make sure you connect to the output, e.g. the
|
|---|
| 183 | readyReadStdout() and <a href="#readyReadStderr">readyReadStderr</a>() signals and read the data
|
|---|
| 184 | as soon as it becomes available.
|
|---|
| 185 | <p> Please note that QProcess does not emulate a shell. This means that
|
|---|
| 186 | QProcess does not do any expansion of arguments: a '*' is passed as a '*'
|
|---|
| 187 | to the program and is <em>not</em> replaced by all the files, a '$HOME' is also
|
|---|
| 188 | passed literally and is <em>not</em> replaced by the environment variable HOME
|
|---|
| 189 | and the special characters for IO redirection ('>', '|', etc.) are also
|
|---|
| 190 | passed literally and do <em>not</em> have the special meaning as they have in a
|
|---|
| 191 | shell.
|
|---|
| 192 | <p> Also note that QProcess does not emulate a terminal. This means that
|
|---|
| 193 | certain programs which need direct terminal control, do not work as
|
|---|
| 194 | expected with QProcess. Such programs include console email programs (like
|
|---|
| 195 | pine and mutt) but also programs which require the user to enter a password
|
|---|
| 196 | (like su and ssh).
|
|---|
| 197 | <p> <h3> Notes for Windows users
|
|---|
| 198 | </h3>
|
|---|
| 199 | <a name="1"></a><p> Some Windows commands, for example, <tt>dir</tt>, are not provided by
|
|---|
| 200 | separate applications, but by the command interpreter.
|
|---|
| 201 | If you attempt to use QProcess to execute these commands directly
|
|---|
| 202 | it won't work. One possible solution is to execute the command
|
|---|
| 203 | interpreter itself (<tt>cmd.exe</tt> on some Windows systems), and ask
|
|---|
| 204 | the interpreter to execute the desired command.
|
|---|
| 205 | <p> Under Windows there are certain problems starting 16-bit applications
|
|---|
| 206 | and capturing their output. Microsoft recommends using an intermediate
|
|---|
| 207 | application to start 16-bit applications.
|
|---|
| 208 | <p> <p>See also <a href="qsocket.html">QSocket</a>, <a href="io.html">Input/Output and Networking</a>, and <a href="misc.html">Miscellaneous Classes</a>.
|
|---|
| 209 |
|
|---|
| 210 | <hr><h2>Member Type Documentation</h2>
|
|---|
| 211 | <h3 class=fn><a name="Communication-enum"></a>QProcess::Communication</h3>
|
|---|
| 212 |
|
|---|
| 213 | <p> This enum type defines the communication channels connected to the
|
|---|
| 214 | process.
|
|---|
| 215 | <ul>
|
|---|
| 216 | <li><tt>QProcess::Stdin</tt> - Data can be written to the process's standard input.
|
|---|
| 217 | <li><tt>QProcess::Stdout</tt> - Data can be read from the process's standard
|
|---|
| 218 | output.
|
|---|
| 219 | <li><tt>QProcess::Stderr</tt> - Data can be read from the process's standard error.
|
|---|
| 220 | <li><tt>QProcess::DupStderr</tt> - Both the process's standard error output <em>and</em>
|
|---|
| 221 | its standard output are written to its standard output. (Like
|
|---|
| 222 | Unix's dup2().) This means that nothing is sent to the standard
|
|---|
| 223 | error output. This is especially useful if your application
|
|---|
| 224 | requires that the output on standard output and on standard error
|
|---|
| 225 | must be read in the same order that they are produced. This is a
|
|---|
| 226 | flag, so to activate it you must pass <tt>Stdout|Stderr|DupStderr</tt>,
|
|---|
| 227 | or <tt>Stdin|Stdout|Stderr|DupStderr</tt> if you want to provide input,
|
|---|
| 228 | to the <a href="#setCommunication">setCommunication</a>() call.
|
|---|
| 229 | </ul><p> <p>See also <a href="#setCommunication">setCommunication</a>() and <a href="#communication">communication</a>().
|
|---|
| 230 |
|
|---|
| 231 | <hr><h2>Member Function Documentation</h2>
|
|---|
| 232 | <h3 class=fn><a name="QProcess"></a>QProcess::QProcess ( <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
|---|
| 233 | </h3>
|
|---|
| 234 | Constructs a QProcess object. The <em>parent</em> and <em>name</em> parameters
|
|---|
| 235 | are passed to the <a href="qobject.html">QObject</a> constructor.
|
|---|
| 236 | <p> <p>See also <a href="#setArguments">setArguments</a>(), <a href="#addArgument">addArgument</a>(), and <a href="#start">start</a>().
|
|---|
| 237 |
|
|---|
| 238 | <h3 class=fn><a name="QProcess-2"></a>QProcess::QProcess ( const <a href="qstring.html">QString</a> & arg0, <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
|---|
| 239 | </h3>
|
|---|
| 240 | Constructs a QProcess with <em>arg0</em> as the command to be executed.
|
|---|
| 241 | The <em>parent</em> and <em>name</em> parameters are passed to the <a href="qobject.html">QObject</a>
|
|---|
| 242 | constructor.
|
|---|
| 243 | <p> The process is not started. You must call <a href="#start">start</a>() or <a href="#launch">launch</a>() to
|
|---|
| 244 | start the process.
|
|---|
| 245 | <p> <p>See also <a href="#setArguments">setArguments</a>(), <a href="#addArgument">addArgument</a>(), and <a href="#start">start</a>().
|
|---|
| 246 |
|
|---|
| 247 | <h3 class=fn><a name="QProcess-3"></a>QProcess::QProcess ( const <a href="qstringlist.html">QStringList</a> & args, <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
|---|
| 248 | </h3>
|
|---|
| 249 | Constructs a QProcess with <em>args</em> as the arguments of the
|
|---|
| 250 | process. The first element in the list is the command to be
|
|---|
| 251 | executed. The other elements in the list are the arguments to this
|
|---|
| 252 | command. The <em>parent</em> and <em>name</em> parameters are passed to the
|
|---|
| 253 | <a href="qobject.html">QObject</a> constructor.
|
|---|
| 254 | <p> The process is not started. You must call <a href="#start">start</a>() or <a href="#launch">launch</a>() to
|
|---|
| 255 | start the process.
|
|---|
| 256 | <p> <p>See also <a href="#setArguments">setArguments</a>(), <a href="#addArgument">addArgument</a>(), and <a href="#start">start</a>().
|
|---|
| 257 |
|
|---|
| 258 | <h3 class=fn><a name="~QProcess"></a>QProcess::~QProcess ()
|
|---|
| 259 | </h3>
|
|---|
| 260 | Destroys the instance.
|
|---|
| 261 | <p> If the process is running, it is <b>not</b> terminated! The
|
|---|
| 262 | standard input, standard output and standard error of the process
|
|---|
| 263 | are closed.
|
|---|
| 264 | <p> You can connect the <a href="qobject.html#destroyed">destroyed</a>() signal to the <a href="#kill">kill</a>() slot, if you
|
|---|
| 265 | want the process to be terminated automatically when the instance
|
|---|
| 266 | is destroyed.
|
|---|
| 267 | <p> <p>See also <a href="#tryTerminate">tryTerminate</a>() and <a href="#kill">kill</a>().
|
|---|
| 268 |
|
|---|
| 269 | <h3 class=fn>void <a name="addArgument"></a>QProcess::addArgument ( const <a href="qstring.html">QString</a> & arg )<tt> [virtual]</tt>
|
|---|
| 270 | </h3>
|
|---|
| 271 | Adds <em>arg</em> to the end of the list of arguments.
|
|---|
| 272 | <p> The first element in the list of arguments is the command to be
|
|---|
| 273 | executed; the following elements are the command's arguments.
|
|---|
| 274 | <p> <p>See also <a href="#arguments">arguments</a>() and <a href="#setArguments">setArguments</a>().
|
|---|
| 275 |
|
|---|
| 276 | <p>Example: <a href="qprocess.html#x2122">process/process.cpp</a>.
|
|---|
| 277 | <h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="arguments"></a>QProcess::arguments () const
|
|---|
| 278 | </h3>
|
|---|
| 279 | Returns the list of arguments that are set for the process.
|
|---|
| 280 | Arguments can be specified with the constructor or with the
|
|---|
| 281 | functions <a href="#setArguments">setArguments</a>() and <a href="#addArgument">addArgument</a>().
|
|---|
| 282 | <p> Note that if you want to iterate over the list, you should iterate
|
|---|
| 283 | over a copy, e.g.
|
|---|
| 284 | <pre>
|
|---|
| 285 | <a href="qstringlist.html">QStringList</a> list = myProcess.arguments();
|
|---|
| 286 | QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
|---|
| 287 | while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
|---|
| 288 | myProcessing( *it );
|
|---|
| 289 | ++it;
|
|---|
| 290 | }
|
|---|
| 291 | </pre>
|
|---|
| 292 |
|
|---|
| 293 | <p> <p>See also <a href="#setArguments">setArguments</a>() and <a href="#addArgument">addArgument</a>().
|
|---|
| 294 |
|
|---|
| 295 | <h3 class=fn>bool <a name="canReadLineStderr"></a>QProcess::canReadLineStderr () const
|
|---|
| 296 | </h3>
|
|---|
| 297 | Returns TRUE if it's possible to read an entire line of text from
|
|---|
| 298 | standard error at this time; otherwise returns FALSE.
|
|---|
| 299 | <p> <p>See also <a href="#readLineStderr">readLineStderr</a>() and <a href="#canReadLineStdout">canReadLineStdout</a>().
|
|---|
| 300 |
|
|---|
| 301 | <h3 class=fn>bool <a name="canReadLineStdout"></a>QProcess::canReadLineStdout () const
|
|---|
| 302 | </h3>
|
|---|
| 303 | Returns TRUE if it's possible to read an entire line of text from
|
|---|
| 304 | standard output at this time; otherwise returns FALSE.
|
|---|
| 305 | <p> <p>See also <a href="#readLineStdout">readLineStdout</a>() and <a href="#canReadLineStderr">canReadLineStderr</a>().
|
|---|
| 306 |
|
|---|
| 307 | <h3 class=fn>void <a name="clearArguments"></a>QProcess::clearArguments ()
|
|---|
| 308 | </h3>
|
|---|
| 309 | Clears the list of arguments that are set for the process.
|
|---|
| 310 | <p> <p>See also <a href="#setArguments">setArguments</a>() and <a href="#addArgument">addArgument</a>().
|
|---|
| 311 |
|
|---|
| 312 | <h3 class=fn>void <a name="closeStdin"></a>QProcess::closeStdin ()<tt> [virtual slot]</tt>
|
|---|
| 313 | </h3>
|
|---|
| 314 | Closes the process's standard input.
|
|---|
| 315 | <p> This function also deletes any pending data that has not been
|
|---|
| 316 | written to standard input.
|
|---|
| 317 | <p> <p>See also <a href="#wroteToStdin">wroteToStdin</a>().
|
|---|
| 318 |
|
|---|
| 319 | <h3 class=fn>int <a name="communication"></a>QProcess::communication () const
|
|---|
| 320 | </h3>
|
|---|
| 321 | Returns the communication required with the process, i.e. some
|
|---|
| 322 | combination of the <a href="#Communication-enum">Communication</a> flags.
|
|---|
| 323 | <p> <p>See also <a href="#setCommunication">setCommunication</a>().
|
|---|
| 324 |
|
|---|
| 325 | <h3 class=fn>int <a name="exitStatus"></a>QProcess::exitStatus () const
|
|---|
| 326 | </h3>
|
|---|
| 327 | Returns the exit status of the process or 0 if the process is
|
|---|
| 328 | still running. This function returns immediately and does not wait
|
|---|
| 329 | until the process is finished.
|
|---|
| 330 | <p> If <a href="#normalExit">normalExit</a>() is FALSE (e.g. if the program was killed or
|
|---|
| 331 | crashed), this function returns 0, so you should check the return
|
|---|
| 332 | value of normalExit() before relying on this value.
|
|---|
| 333 | <p> <p>See also <a href="#normalExit">normalExit</a>() and <a href="#processExited">processExited</a>().
|
|---|
| 334 |
|
|---|
| 335 | <h3 class=fn>bool <a name="isRunning"></a>QProcess::isRunning () const
|
|---|
| 336 | </h3>
|
|---|
| 337 | Returns TRUE if the process is running; otherwise returns FALSE.
|
|---|
| 338 | <p> <p>See also <a href="#normalExit">normalExit</a>(), <a href="#exitStatus">exitStatus</a>(), and <a href="#processExited">processExited</a>().
|
|---|
| 339 |
|
|---|
| 340 | <h3 class=fn>void <a name="kill"></a>QProcess::kill () const<tt> [slot]</tt>
|
|---|
| 341 | </h3>
|
|---|
| 342 | Terminates the process. This is not a safe way to end a process
|
|---|
| 343 | since the process will not be able to do any cleanup.
|
|---|
| 344 | <a href="#tryTerminate">tryTerminate</a>() is safer, but processes can ignore a
|
|---|
| 345 | tryTerminate().
|
|---|
| 346 | <p> The nice way to end a process and to be sure that it is finished,
|
|---|
| 347 | is to do something like this:
|
|---|
| 348 | <pre>
|
|---|
| 349 | process->tryTerminate();
|
|---|
| 350 | QTimer::<a href="qtimer.html#singleShot">singleShot</a>( 5000, process, SLOT( <a href="#kill">kill</a>() ) );
|
|---|
| 351 | </pre>
|
|---|
| 352 |
|
|---|
| 353 | <p> This tries to terminate the process the nice way. If the process
|
|---|
| 354 | is still running after 5 seconds, it terminates the process the
|
|---|
| 355 | hard way. The timeout should be chosen depending on the time the
|
|---|
| 356 | process needs to do all its cleanup: use a higher value if the
|
|---|
| 357 | process is likely to do a lot of computation or I/O on cleanup.
|
|---|
| 358 | <p> The slot returns immediately: it does not wait until the process
|
|---|
| 359 | has finished. When the process terminates, the <a href="#processExited">processExited</a>()
|
|---|
| 360 | signal is emitted.
|
|---|
| 361 | <p> <p>See also <a href="#tryTerminate">tryTerminate</a>() and <a href="#processExited">processExited</a>().
|
|---|
| 362 |
|
|---|
| 363 | <h3 class=fn>bool <a name="launch"></a>QProcess::launch ( const <a href="qbytearray.html">QByteArray</a> & buf, <a href="qstringlist.html">QStringList</a> * env = 0 )<tt> [virtual]</tt>
|
|---|
| 364 | </h3>
|
|---|
| 365 | Runs the process and writes the data <em>buf</em> to the process's
|
|---|
| 366 | standard input. If all the data is written to standard input,
|
|---|
| 367 | standard input is closed. The command is searched for in the path
|
|---|
| 368 | for executable programs; you can also use an absolute path in the
|
|---|
| 369 | command itself.
|
|---|
| 370 | <p> If <em>env</em> is null, then the process is started with the same
|
|---|
| 371 | environment as the starting process. If <em>env</em> is non-null, then
|
|---|
| 372 | the values in the string list are interpreted as environment
|
|---|
| 373 | setttings of the form <tt>key=value</tt> and the process is started
|
|---|
| 374 | with these environment settings. For convenience, there is a small
|
|---|
| 375 | exception to this rule under Unix: if <em>env</em> does not contain any
|
|---|
| 376 | settings for the environment variable <tt>LD_LIBRARY_PATH</tt>, then
|
|---|
| 377 | this variable is inherited from the starting process.
|
|---|
| 378 | <p> Returns TRUE if the process could be started; otherwise returns
|
|---|
| 379 | FALSE.
|
|---|
| 380 | <p> Note that you should not use the slots <a href="#writeToStdin">writeToStdin</a>() and
|
|---|
| 381 | <a href="#closeStdin">closeStdin</a>() on processes started with <a href="#launch">launch</a>(), since the result
|
|---|
| 382 | is not well-defined. If you need these slots, use <a href="#start">start</a>() instead.
|
|---|
| 383 | <p> The process may or may not read the <em>buf</em> data sent to its
|
|---|
| 384 | standard input.
|
|---|
| 385 | <p> You can call this function even when a process that was started
|
|---|
| 386 | with this instance is still running. Be aware that if you do this
|
|---|
| 387 | the standard input of the process that was launched first will be
|
|---|
| 388 | closed, with any pending data being deleted, and the process will
|
|---|
| 389 | be left to run out of your control. Similarly, if the process
|
|---|
| 390 | could not be started the standard input will be closed and the
|
|---|
| 391 | pending data deleted. (On operating systems that have zombie
|
|---|
| 392 | processes, Qt will also wait() on the old process.)
|
|---|
| 393 | <p> The object emits the signal <a href="#launchFinished">launchFinished</a>() when this function
|
|---|
| 394 | call is finished. If the start was successful, this signal is
|
|---|
| 395 | emitted after all the data has been written to standard input. If
|
|---|
| 396 | the start failed, then this signal is emitted immediately.
|
|---|
| 397 | <p> <p>See also <a href="#start">start</a>() and <a href="#launchFinished">launchFinished</a>().
|
|---|
| 398 |
|
|---|
| 399 | <h3 class=fn>bool <a name="launch-2"></a>QProcess::launch ( const <a href="qstring.html">QString</a> & buf, <a href="qstringlist.html">QStringList</a> * env = 0 )<tt> [virtual]</tt>
|
|---|
| 400 | </h3>
|
|---|
| 401 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|---|
| 402 | <p> The data <em>buf</em> is written to standard input with <a href="#writeToStdin">writeToStdin</a>()
|
|---|
| 403 | using the <a href="qstring.html#local8Bit">QString::local8Bit</a>() representation of the strings.
|
|---|
| 404 |
|
|---|
| 405 | <h3 class=fn>void <a name="launchFinished"></a>QProcess::launchFinished ()<tt> [signal]</tt>
|
|---|
| 406 | </h3>
|
|---|
| 407 |
|
|---|
| 408 | <p> This signal is emitted when the process was started with <a href="#launch">launch</a>().
|
|---|
| 409 | If the start was successful, this signal is emitted after all the
|
|---|
| 410 | data has been written to standard input. If the start failed, then
|
|---|
| 411 | this signal is emitted immediately.
|
|---|
| 412 | <p> This signal is especially useful if you want to know when you can
|
|---|
| 413 | safely delete the QProcess object when you are not interested in
|
|---|
| 414 | reading from standard output or standard error.
|
|---|
| 415 | <p> <p>See also <a href="#launch">launch</a>() and <a href="qobject.html#deleteLater">QObject::deleteLater</a>().
|
|---|
| 416 |
|
|---|
| 417 | <h3 class=fn>bool <a name="normalExit"></a>QProcess::normalExit () const
|
|---|
| 418 | </h3>
|
|---|
| 419 | Returns TRUE if the process has exited normally; otherwise returns
|
|---|
| 420 | FALSE. This implies that this function returns FALSE if the
|
|---|
| 421 | process is still running.
|
|---|
| 422 | <p> <p>See also <a href="#isRunning">isRunning</a>(), <a href="#exitStatus">exitStatus</a>(), and <a href="#processExited">processExited</a>().
|
|---|
| 423 |
|
|---|
| 424 | <h3 class=fn>void <a name="processExited"></a>QProcess::processExited ()<tt> [signal]</tt>
|
|---|
| 425 | </h3>
|
|---|
| 426 |
|
|---|
| 427 | <p> This signal is emitted when the process has exited.
|
|---|
| 428 | <p> <p>See also <a href="#isRunning">isRunning</a>(), <a href="#normalExit">normalExit</a>(), <a href="#exitStatus">exitStatus</a>(), <a href="#start">start</a>(), and <a href="#launch">launch</a>().
|
|---|
| 429 |
|
|---|
| 430 | <p>Example: <a href="process-example.html#x98">process/process.cpp</a>.
|
|---|
| 431 | <h3 class=fn>PID <a name="processIdentifier"></a>QProcess::processIdentifier ()
|
|---|
| 432 | </h3>
|
|---|
| 433 | Returns platform dependent information about the process. This can
|
|---|
| 434 | be used together with platform specific system calls.
|
|---|
| 435 | <p> Under Unix the return value is the PID of the process, or -1 if no
|
|---|
| 436 | process belongs to this object.
|
|---|
| 437 | <p> Under Windows it is a pointer to the <tt>PROCESS_INFORMATION</tt>
|
|---|
| 438 | struct, or 0 if no process is belongs to this object.
|
|---|
| 439 | <p> Use of this function's return value is likely to be non-portable.
|
|---|
| 440 |
|
|---|
| 441 | <h3 class=fn><a href="qstring.html">QString</a> <a name="readLineStderr"></a>QProcess::readLineStderr ()<tt> [virtual]</tt>
|
|---|
| 442 | </h3>
|
|---|
| 443 | Reads a line of text from standard error, excluding any trailing
|
|---|
| 444 | newline or carriage return characters and returns it. Returns
|
|---|
| 445 | <a href="qstring.html#QString-null">QString::null</a> if <a href="#canReadLineStderr">canReadLineStderr</a>() returns FALSE.
|
|---|
| 446 | <p> By default, the text is interpreted to be in Latin-1 encoding. If you need
|
|---|
| 447 | other codecs, you can set a different codec with
|
|---|
| 448 | <a href="qtextcodec.html#setCodecForCStrings">QTextCodec::setCodecForCStrings</a>().
|
|---|
| 449 | <p> <p>See also <a href="#canReadLineStderr">canReadLineStderr</a>(), <a href="#readyReadStderr">readyReadStderr</a>(), <a href="#readStderr">readStderr</a>(), and <a href="#readLineStdout">readLineStdout</a>().
|
|---|
| 450 |
|
|---|
| 451 | <h3 class=fn><a href="qstring.html">QString</a> <a name="readLineStdout"></a>QProcess::readLineStdout ()<tt> [virtual]</tt>
|
|---|
| 452 | </h3>
|
|---|
| 453 | Reads a line of text from standard output, excluding any trailing
|
|---|
| 454 | newline or carriage return characters, and returns it. Returns
|
|---|
| 455 | <a href="qstring.html#QString-null">QString::null</a> if <a href="#canReadLineStdout">canReadLineStdout</a>() returns FALSE.
|
|---|
| 456 | <p> By default, the text is interpreted to be in Latin-1 encoding. If you need
|
|---|
| 457 | other codecs, you can set a different codec with
|
|---|
| 458 | <a href="qtextcodec.html#setCodecForCStrings">QTextCodec::setCodecForCStrings</a>().
|
|---|
| 459 | <p> <p>See also <a href="#canReadLineStdout">canReadLineStdout</a>(), <a href="#readyReadStdout">readyReadStdout</a>(), <a href="#readStdout">readStdout</a>(), and <a href="#readLineStderr">readLineStderr</a>().
|
|---|
| 460 |
|
|---|
| 461 | <h3 class=fn><a href="qbytearray.html">QByteArray</a> <a name="readStderr"></a>QProcess::readStderr ()<tt> [virtual]</tt>
|
|---|
| 462 | </h3>
|
|---|
| 463 | Reads the data that the process has written to standard error.
|
|---|
| 464 | When new data is written to standard error, the class emits the
|
|---|
| 465 | signal <a href="#readyReadStderr">readyReadStderr</a>().
|
|---|
| 466 | <p> If there is no data to read, this function returns a <a href="qbytearray.html">QByteArray</a> of
|
|---|
| 467 | size 0: it does not wait until there is something to read.
|
|---|
| 468 | <p> <p>See also <a href="#readyReadStderr">readyReadStderr</a>(), <a href="#readLineStderr">readLineStderr</a>(), <a href="#readStdout">readStdout</a>(), and <a href="#writeToStdin">writeToStdin</a>().
|
|---|
| 469 |
|
|---|
| 470 | <h3 class=fn><a href="qbytearray.html">QByteArray</a> <a name="readStdout"></a>QProcess::readStdout ()<tt> [virtual]</tt>
|
|---|
| 471 | </h3>
|
|---|
| 472 | Reads the data that the process has written to standard output.
|
|---|
| 473 | When new data is written to standard output, the class emits the
|
|---|
| 474 | signal <a href="#readyReadStdout">readyReadStdout</a>().
|
|---|
| 475 | <p> If there is no data to read, this function returns a <a href="qbytearray.html">QByteArray</a> of
|
|---|
| 476 | size 0: it does not wait until there is something to read.
|
|---|
| 477 | <p> <p>See also <a href="#readyReadStdout">readyReadStdout</a>(), <a href="#readLineStdout">readLineStdout</a>(), <a href="#readStderr">readStderr</a>(), and <a href="#writeToStdin">writeToStdin</a>().
|
|---|
| 478 |
|
|---|
| 479 | <p>Example: <a href="process-example.html#x99">process/process.cpp</a>.
|
|---|
| 480 | <h3 class=fn>void <a name="readyReadStderr"></a>QProcess::readyReadStderr ()<tt> [signal]</tt>
|
|---|
| 481 | </h3>
|
|---|
| 482 |
|
|---|
| 483 | <p> This signal is emitted when the process has written data to
|
|---|
| 484 | standard error. You can read the data with <a href="#readStderr">readStderr</a>().
|
|---|
| 485 | <p> Note that this signal is only emitted when there is new data and
|
|---|
| 486 | not when there is old, but unread data. In the slot connected to
|
|---|
| 487 | this signal, you should always read everything that is available
|
|---|
| 488 | at that moment to make sure that you don't lose any data.
|
|---|
| 489 | <p> <p>See also <a href="#readStderr">readStderr</a>(), <a href="#readLineStderr">readLineStderr</a>(), and <a href="#readyReadStdout">readyReadStdout</a>().
|
|---|
| 490 |
|
|---|
| 491 | <h3 class=fn>void <a name="readyReadStdout"></a>QProcess::readyReadStdout ()<tt> [signal]</tt>
|
|---|
| 492 | </h3>
|
|---|
| 493 |
|
|---|
| 494 | <p> This signal is emitted when the process has written data to
|
|---|
| 495 | standard output. You can read the data with <a href="#readStdout">readStdout</a>().
|
|---|
| 496 | <p> Note that this signal is only emitted when there is new data and
|
|---|
| 497 | not when there is old, but unread data. In the slot connected to
|
|---|
| 498 | this signal, you should always read everything that is available
|
|---|
| 499 | at that moment to make sure that you don't lose any data.
|
|---|
| 500 | <p> <p>See also <a href="#readStdout">readStdout</a>(), <a href="#readLineStdout">readLineStdout</a>(), and <a href="#readyReadStderr">readyReadStderr</a>().
|
|---|
| 501 |
|
|---|
| 502 | <p>Example: <a href="qprocess.html#x2123">process/process.cpp</a>.
|
|---|
| 503 | <h3 class=fn>void <a name="setArguments"></a>QProcess::setArguments ( const <a href="qstringlist.html">QStringList</a> & args )<tt> [virtual]</tt>
|
|---|
| 504 | </h3>
|
|---|
| 505 | Sets <em>args</em> as the arguments for the process. The first element
|
|---|
| 506 | in the list is the command to be executed. The other elements in
|
|---|
| 507 | the list are the arguments to the command. Any previous arguments
|
|---|
| 508 | are deleted.
|
|---|
| 509 | <p> QProcess does not perform argument substitutions; for example, if you
|
|---|
| 510 | specify "*" or "$DISPLAY", these values are passed to the process
|
|---|
| 511 | literally. If you want to have the same behavior as the shell
|
|---|
| 512 | provides, you must do the substitutions yourself; i.e. instead of
|
|---|
| 513 | specifying a "*" you must specify the list of all the filenames in
|
|---|
| 514 | the current directory, and instead of "$DISPLAY" you must specify
|
|---|
| 515 | the value of the environment variable <tt>DISPLAY</tt>.
|
|---|
| 516 | <p> Note for Windows users. The standard Windows shells, e.g. <tt>command.com</tt> and <tt>cmd.exe</tt>, do not perform file globbing, i.e.
|
|---|
| 517 | they do not convert a "*" on the command line into a list of files
|
|---|
| 518 | in the current directory. For this reason most Windows
|
|---|
| 519 | applications implement their own file globbing, and as a result of
|
|---|
| 520 | this, specifying an argument of "*" for a Windows application is
|
|---|
| 521 | likely to result in the application performing a file glob and
|
|---|
| 522 | ending up with a list of filenames.
|
|---|
| 523 | <p> <p>See also <a href="#arguments">arguments</a>() and <a href="#addArgument">addArgument</a>().
|
|---|
| 524 |
|
|---|
| 525 | <h3 class=fn>void <a name="setCommunication"></a>QProcess::setCommunication ( int commFlags )
|
|---|
| 526 | </h3>
|
|---|
| 527 | Sets <em>commFlags</em> as the communication required with the process.
|
|---|
| 528 | <p> <em>commFlags</em> is a bitwise OR of the flags defined by the <a href="#Communication-enum">Communication</a> enum.
|
|---|
| 529 | <p> The default is <tt>Stdin|Stdout|Stderr</tt>.
|
|---|
| 530 | <p> <p>See also <a href="#communication">communication</a>().
|
|---|
| 531 |
|
|---|
| 532 | <h3 class=fn>void <a name="setWorkingDirectory"></a>QProcess::setWorkingDirectory ( const <a href="qdir.html">QDir</a> & dir )<tt> [virtual]</tt>
|
|---|
| 533 | </h3>
|
|---|
| 534 | Sets <em>dir</em> as the working directory for processes. This does not
|
|---|
| 535 | affect running processes; only processes that are started
|
|---|
| 536 | afterwards are affected.
|
|---|
| 537 | <p> Setting the working directory is especially useful for processes
|
|---|
| 538 | that try to access files with relative paths.
|
|---|
| 539 | <p> <p>See also <a href="#workingDirectory">workingDirectory</a>() and <a href="#start">start</a>().
|
|---|
| 540 |
|
|---|
| 541 | <h3 class=fn>bool <a name="start"></a>QProcess::start ( <a href="qstringlist.html">QStringList</a> * env = 0 )<tt> [virtual]</tt>
|
|---|
| 542 | </h3>
|
|---|
| 543 | Tries to run a process for the command and arguments that were
|
|---|
| 544 | specified with <a href="#setArguments">setArguments</a>(), <a href="#addArgument">addArgument</a>() or that were
|
|---|
| 545 | specified in the constructor. The command is searched for in the
|
|---|
| 546 | path for executable programs; you can also use an absolute path in
|
|---|
| 547 | the command itself.
|
|---|
| 548 | <p> If <em>env</em> is null, then the process is started with the same
|
|---|
| 549 | environment as the starting process. If <em>env</em> is non-null, then
|
|---|
| 550 | the values in the stringlist are interpreted as environment
|
|---|
| 551 | setttings of the form <tt>key=value</tt> and the process is started in
|
|---|
| 552 | these environment settings. For convenience, there is a small
|
|---|
| 553 | exception to this rule: under Unix, if <em>env</em> does not contain any
|
|---|
| 554 | settings for the environment variable <tt>LD_LIBRARY_PATH</tt>, then
|
|---|
| 555 | this variable is inherited from the starting process; under
|
|---|
| 556 | Windows the same applies for the environment variable <tt>PATH</tt>.
|
|---|
| 557 | <p> Returns TRUE if the process could be started; otherwise returns
|
|---|
| 558 | FALSE.
|
|---|
| 559 | <p> You can write data to the process's standard input with
|
|---|
| 560 | <a href="#writeToStdin">writeToStdin</a>(). You can close standard input with <a href="#closeStdin">closeStdin</a>() and
|
|---|
| 561 | you can terminate the process with <a href="#tryTerminate">tryTerminate</a>(), or with <a href="#kill">kill</a>().
|
|---|
| 562 | <p> You can call this function even if you've used this instance to
|
|---|
| 563 | create a another process which is still running. In such cases,
|
|---|
| 564 | QProcess closes the old process's standard input and deletes
|
|---|
| 565 | pending data, i.e., you lose all control over the old process, but
|
|---|
| 566 | the old process is not terminated. This applies also if the
|
|---|
| 567 | process could not be started. (On operating systems that have
|
|---|
| 568 | zombie processes, Qt will also wait() on the old process.)
|
|---|
| 569 | <p> <p>See also <a href="#launch">launch</a>() and <a href="#closeStdin">closeStdin</a>().
|
|---|
| 570 |
|
|---|
| 571 | <p>Example: <a href="qprocess.html#x2124">process/process.cpp</a>.
|
|---|
| 572 | <h3 class=fn>void <a name="tryTerminate"></a>QProcess::tryTerminate () const<tt> [slot]</tt>
|
|---|
| 573 | </h3>
|
|---|
| 574 | Asks the process to terminate. Processes can ignore this if they
|
|---|
| 575 | wish. If you want to be certain that the process really
|
|---|
| 576 | terminates, you can use <a href="#kill">kill</a>() instead.
|
|---|
| 577 | <p> The slot returns immediately: it does not wait until the process
|
|---|
| 578 | has finished. When the process terminates, the <a href="#processExited">processExited</a>()
|
|---|
| 579 | signal is emitted.
|
|---|
| 580 | <p> <p>See also <a href="#kill">kill</a>() and <a href="#processExited">processExited</a>().
|
|---|
| 581 |
|
|---|
| 582 | <h3 class=fn><a href="qdir.html">QDir</a> <a name="workingDirectory"></a>QProcess::workingDirectory () const
|
|---|
| 583 | </h3>
|
|---|
| 584 | Returns the working directory that was set with
|
|---|
| 585 | <a href="#setWorkingDirectory">setWorkingDirectory</a>(), or the current directory if none has been
|
|---|
| 586 | explicitly set.
|
|---|
| 587 | <p> <p>See also <a href="#setWorkingDirectory">setWorkingDirectory</a>() and <a href="qdir.html#current">QDir::current</a>().
|
|---|
| 588 |
|
|---|
| 589 | <h3 class=fn>void <a name="writeToStdin"></a>QProcess::writeToStdin ( const <a href="qbytearray.html">QByteArray</a> & buf )<tt> [virtual slot]</tt>
|
|---|
| 590 | </h3>
|
|---|
| 591 | Writes the data <em>buf</em> to the process's standard input. The
|
|---|
| 592 | process may or may not read this data.
|
|---|
| 593 | <p> This function always returns immediately. The data you
|
|---|
| 594 | pass to <a href="#writeToStdin">writeToStdin</a>() is copied into an internal memory buffer in
|
|---|
| 595 | QProcess, and when control goes back to the event loop, QProcess will
|
|---|
| 596 | starting transferring data from this buffer to the running process.
|
|---|
| 597 | Sometimes the data will be transferred in several payloads, depending on
|
|---|
| 598 | how much data is read at a time by the process itself. When QProcess has
|
|---|
| 599 | transferred all the data from its memory buffer to the running process, it
|
|---|
| 600 | emits <a href="#wroteToStdin">wroteToStdin</a>().
|
|---|
| 601 | <p> Note that some operating systems use a buffer to transfer
|
|---|
| 602 | the data. As a result, wroteToStdin() may be emitted before the
|
|---|
| 603 | running process has actually read all the data.
|
|---|
| 604 | <p> <p>See also <a href="#wroteToStdin">wroteToStdin</a>(), <a href="#closeStdin">closeStdin</a>(), <a href="#readStdout">readStdout</a>(), and <a href="#readStderr">readStderr</a>().
|
|---|
| 605 |
|
|---|
| 606 | <h3 class=fn>void <a name="writeToStdin-2"></a>QProcess::writeToStdin ( const <a href="qstring.html">QString</a> & buf )<tt> [virtual slot]</tt>
|
|---|
| 607 | </h3>
|
|---|
| 608 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|---|
| 609 | <p> The string <em>buf</em> is handled as text using the
|
|---|
| 610 | <a href="qstring.html#local8Bit">QString::local8Bit</a>() representation.
|
|---|
| 611 |
|
|---|
| 612 | <h3 class=fn>void <a name="wroteToStdin"></a>QProcess::wroteToStdin ()<tt> [signal]</tt>
|
|---|
| 613 | </h3>
|
|---|
| 614 |
|
|---|
| 615 | <p> This signal is emitted if the data sent to standard input (via
|
|---|
| 616 | <a href="#writeToStdin">writeToStdin</a>()) was actually written to the process. This does not
|
|---|
| 617 | imply that the process really read the data, since this class only
|
|---|
| 618 | detects when it was able to write the data to the operating
|
|---|
| 619 | system. But it is now safe to close standard input without losing
|
|---|
| 620 | pending data.
|
|---|
| 621 | <p> <p>See also <a href="#writeToStdin">writeToStdin</a>() and <a href="#closeStdin">closeStdin</a>().
|
|---|
| 622 |
|
|---|
| 623 | <!-- eof -->
|
|---|
| 624 | <hr><p>
|
|---|
| 625 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
|---|
| 626 | Copyright © 1995-2007
|
|---|
| 627 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
|---|
| 628 | <table width=100% cellspacing=0 border=0><tr>
|
|---|
| 629 | <td>Copyright © 2007
|
|---|
| 630 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
|---|
| 631 | <td align=right><div align=right>Qt 3.3.8</div>
|
|---|
| 632 | </table></div></address></body>
|
|---|
| 633 | </html>
|
|---|