1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
'\" t
.TH QProcess 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QProcess \- Used to start external programs and to communicate with them
.SH SYNOPSIS
\fC#include <ntqprocess.h>\fR
.PP
Inherits QObject.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQProcess\fR ( QObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQProcess\fR ( const QString & arg0, QObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQProcess\fR ( const QStringList & args, QObject * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "\fB~QProcess\fR ()"
.br
.ti -1c
.BI "QStringList \fBarguments\fR () const"
.br
.ti -1c
.BI "void \fBclearArguments\fR ()"
.br
.ti -1c
.BI "virtual void \fBsetArguments\fR ( const QStringList & args )"
.br
.ti -1c
.BI "virtual void \fBaddArgument\fR ( const QString & arg )"
.br
.ti -1c
.BI "QDir \fBworkingDirectory\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetWorkingDirectory\fR ( const QDir & dir )"
.br
.ti -1c
.BI "enum \fBCommunication\fR { Stdin = 0x01, Stdout = 0x02, Stderr = 0x04, DupStderr = 0x08 }"
.br
.ti -1c
.BI "void \fBsetCommunication\fR ( int commFlags )"
.br
.ti -1c
.BI "int \fBcommunication\fR () const"
.br
.ti -1c
.BI "virtual bool \fBstart\fR ( QStringList * env = 0 )"
.br
.ti -1c
.BI "virtual bool \fBlaunch\fR ( const QString & buf, QStringList * env = 0 )"
.br
.ti -1c
.BI "virtual bool \fBlaunch\fR ( const QByteArray & buf, QStringList * env = 0 )"
.br
.ti -1c
.BI "bool \fBisRunning\fR () const"
.br
.ti -1c
.BI "bool \fBnormalExit\fR () const"
.br
.ti -1c
.BI "int \fBexitStatus\fR () const"
.br
.ti -1c
.BI "virtual QByteArray \fBreadStdout\fR ()"
.br
.ti -1c
.BI "virtual QByteArray \fBreadStderr\fR ()"
.br
.ti -1c
.BI "bool \fBcanReadLineStdout\fR () const"
.br
.ti -1c
.BI "bool \fBcanReadLineStderr\fR () const"
.br
.ti -1c
.BI "virtual QString \fBreadLineStdout\fR ()"
.br
.ti -1c
.BI "virtual QString \fBreadLineStderr\fR ()"
.br
.ti -1c
.BI "PID \fBprocessIdentifier\fR ()"
.br
.in -1c
.SS "Public Slots"
.in +1c
.ti -1c
.BI "void \fBtryTerminate\fR () const"
.br
.ti -1c
.BI "void \fBkill\fR () const"
.br
.ti -1c
.BI "virtual void \fBwriteToStdin\fR ( const QByteArray & buf )"
.br
.ti -1c
.BI "virtual void \fBwriteToStdin\fR ( const QString & buf )"
.br
.ti -1c
.BI "virtual void \fBcloseStdin\fR ()"
.br
.in -1c
.SS "Signals"
.in +1c
.ti -1c
.BI "void \fBreadyReadStdout\fR ()"
.br
.ti -1c
.BI "void \fBreadyReadStderr\fR ()"
.br
.ti -1c
.BI "void \fBprocessExited\fR ()"
.br
.ti -1c
.BI "void \fBwroteToStdin\fR ()"
.br
.ti -1c
.BI "void \fBlaunchFinished\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QProcess class is used to start external programs and to communicate with them.
.PP
You can write to the started program's standard input, and can read the program's standard output and standard error. You can pass command line arguments to the program either in the constructor or with setArguments() or addArgument(). The program's working directory can be set with setWorkingDirectory(). If you need to set up environment variables pass them to the start() or launch() functions (see below). The processExited() signal is emitted if the program exits. The program's exit status is available from exitStatus(), although you could simply call normalExit() to see if the program terminated normally.
.PP
There are two different ways to start a process. If you just want to run a program, optionally passing data to its standard input at the beginning, use one of the launch() functions. If you want full control of the program's standard input (especially if you don't know all the data you want to send to standard input at the beginning), use the start() function.
.PP
If you use start() you can write to the program's standard input using writeToStdin() and you can close the standard input with closeStdin(). The wroteToStdin() signal is emitted if the data sent to standard input has been written. You can read from the program's standard output using readStdout() or readLineStdout(). These functions return an empty QByteArray if there is no data to read. The readyReadStdout() signal is emitted when there is data available to be read from standard output. Standard error has a set of functions that correspond to the standard output functions, i.e. readStderr(), readLineStderr() and readyReadStderr().
.PP
If you use one of the launch() functions the data you pass will be sent to the program's standard input which will be closed once all the data has been written. You should \fInot\fR use writeToStdin() or closeStdin() if you use launch(). If you need to send data to the program's standard input after it has started running use start() instead of launch().
.PP
Both start() and launch() can accept a string list of strings each of which has the format, key=value, where the keys are the names of environment variables.
.PP
You can test to see if a program is running with isRunning(). The program's process identifier is available from processIdentifier(). If you want to terminate a running program use tryTerminate(), but note that the program may ignore this. If you \fIreally\fR want to terminate the program, without it having any chance to clean up, you can use kill().
.PP
As an example, suppose we want to start the \fCuic\fR command (a Qt command line tool used with \fIQt Designer\fR) and perform some operations on the output (the \fCuic\fR outputs the code it generates to standard output by default). Suppose further that we want to run the program on the file "small_dialog.ui" with the command line options "-tr i18n". On the command line we would write:
.PP
.nf
.br
uic -tr i18n small_dialog.ui
.br
.fi
.PP
A code snippet for this with the QProcess class might look like this:
.PP
.nf
.br
UicManager::UicManager()
.br
{
.fi
.PP
.nf
.br
proc = new QProcess( this );
.fi
.PP
.nf
.br
proc->addArgument( "uic" );
.br
proc->addArgument( "-tr" );
.br
proc->addArgument( "i18n" );
.br
proc->addArgument( "small_dialog.ui" );
.br
.br
connect( proc, SIGNAL(readyReadStdout()),
.br
this, SLOT(readFromStdout()) );
.fi
.PP
.nf
.br
if ( !proc->start() ) {
.br
// error handling
.fi
.PP
.nf
.br
}
.br
}
.fi
.PP
.nf
.br
void UicManager::readFromStdout()
.br
{
.br
// Read and process the data.
.br
// Bear in mind that the data might be output in chunks.
.fi
.PP
.nf
.br
}
.fi
.PP
Although you may need quotes for a file named on the command line (e.g. if it contains spaces) you shouldn't use extra quotes for arguments passed to addArgument() or setArguments().
.PP
The readyReadStdout() signal is emitted when there is new data on standard output. This happens asynchronously: you don't know if more data will arrive later.
.PP
In the above example you could connect the processExited() signal to the slot UicManager::readFromStdout() instead. If you do so, you will be certain that all the data is available when the slot is called. On the other hand, you must wait until the process has finished before doing any processing.
.PP
Note that if you are expecting a lot of output from the process, you may hit platform-dependent limits to the pipe buffer size. The solution is to make sure you connect to the output, e.g. the readyReadStdout() and readyReadStderr() signals and read the data as soon as it becomes available.
.PP
Please note that QProcess does not emulate a shell. This means that QProcess does not do any expansion of arguments: a '*' is passed as a '*' to the program and is \fInot\fR replaced by all the files, a '$HOME' is also passed literally and is \fInot\fR replaced by the environment variable HOME and the special characters for IO redirection ('>', '|', etc.) are also passed literally and do \fInot\fR have the special meaning as they have in a shell.
.PP
Also note that QProcess does not emulate a terminal. This means that certain programs which need direct terminal control, do not work as expected with QProcess. Such programs include console email programs (like pine and mutt) but also programs which require the user to enter a password (like su and ssh).
.SH "Notes for Windows users"
Some Windows commands, for example, \fCdir\fR, are not provided by separate applications, but by the command interpreter. 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 (\fCcmd.exe\fR on some Windows systems), and ask the interpreter to execute the desired command.
.PP
Under Windows there are certain problems starting 16-bit applications and capturing their output. Microsoft recommends using an intermediate application to start 16-bit applications.
.PP
See also QSocket, Input/Output and Networking, and Miscellaneous Classes.
.SS "Member Type Documentation"
.SH "QProcess::Communication"
This enum type defines the communication channels connected to the process.
.TP
\fCQProcess::Stdin\fR - Data can be written to the process's standard input.
.TP
\fCQProcess::Stdout\fR - Data can be read from the process's standard output.
.TP
\fCQProcess::Stderr\fR - Data can be read from the process's standard error.
.TP
\fCQProcess::DupStderr\fR - Both the process's standard error output \fIand\fR its standard output are written to its standard output. (Like Unix's dup2().) This means that nothing is sent to the standard error output. This is especially useful if your application requires that the output on standard output and on standard error must be read in the same order that they are produced. This is a flag, so to activate it you must pass \fCStdout|Stderr|DupStderr\fR, or \fCStdin|Stdout|Stderr|DupStderr\fR if you want to provide input, to the setCommunication() call.
.PP
See also setCommunication() and communication().
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QProcess::QProcess ( QObject * parent = 0, const char * name = 0 )"
Constructs a QProcess object. The \fIparent\fR and \fIname\fR parameters are passed to the QObject constructor.
.PP
See also setArguments(), addArgument(), and start().
.SH "QProcess::QProcess ( const QString & arg0, QObject * parent = 0, const char * name = 0 )"
Constructs a QProcess with \fIarg0\fR as the command to be executed. The \fIparent\fR and \fIname\fR parameters are passed to the QObject constructor.
.PP
The process is not started. You must call start() or launch() to start the process.
.PP
See also setArguments(), addArgument(), and start().
.SH "QProcess::QProcess ( const QStringList & args, QObject * parent = 0, const char * name = 0 )"
Constructs a QProcess with \fIargs\fR as the arguments of the process. The first element in the list is the command to be executed. The other elements in the list are the arguments to this command. The \fIparent\fR and \fIname\fR parameters are passed to the QObject constructor.
.PP
The process is not started. You must call start() or launch() to start the process.
.PP
See also setArguments(), addArgument(), and start().
.SH "QProcess::~QProcess ()"
Destroys the instance.
.PP
If the process is running, it is \fBnot\fR terminated! The standard input, standard output and standard error of the process are closed.
.PP
You can connect the destroyed() signal to the kill() slot, if you want the process to be terminated automatically when the instance is destroyed.
.PP
See also tryTerminate() and kill().
.SH "void QProcess::addArgument ( const QString & arg )\fC [virtual]\fR"
Adds \fIarg\fR to the end of the list of arguments.
.PP
The first element in the list of arguments is the command to be executed; the following elements are the command's arguments.
.PP
See also arguments() and setArguments().
.PP
Example: process/process.cpp.
.SH "QStringList QProcess::arguments () const"
Returns the list of arguments that are set for the process. Arguments can be specified with the constructor or with the functions setArguments() and addArgument().
.PP
Note that if you want to iterate over the list, you should iterate over a copy, e.g.
.PP
.nf
.br
QStringList list = myProcess.arguments();
.br
QStringList::Iterator it = list.begin();
.br
while( it != list.end() ) {
.br
myProcessing( *it );
.br
++it;
.br
}
.br
.fi
.PP
See also setArguments() and addArgument().
.SH "bool QProcess::canReadLineStderr () const"
Returns TRUE if it's possible to read an entire line of text from standard error at this time; otherwise returns FALSE.
.PP
See also readLineStderr() and canReadLineStdout().
.SH "bool QProcess::canReadLineStdout () const"
Returns TRUE if it's possible to read an entire line of text from standard output at this time; otherwise returns FALSE.
.PP
See also readLineStdout() and canReadLineStderr().
.SH "void QProcess::clearArguments ()"
Clears the list of arguments that are set for the process.
.PP
See also setArguments() and addArgument().
.SH "void QProcess::closeStdin ()\fC [virtual slot]\fR"
Closes the process's standard input.
.PP
This function also deletes any pending data that has not been written to standard input.
.PP
See also wroteToStdin().
.SH "int QProcess::communication () const"
Returns the communication required with the process, i.e. some combination of the Communication flags.
.PP
See also setCommunication().
.SH "int QProcess::exitStatus () const"
Returns the exit status of the process or 0 if the process is still running. This function returns immediately and does not wait until the process is finished.
.PP
If normalExit() is FALSE (e.g. if the program was killed or crashed), this function returns 0, so you should check the return value of normalExit() before relying on this value.
.PP
See also normalExit() and processExited().
.SH "bool QProcess::isRunning () const"
Returns TRUE if the process is running; otherwise returns FALSE.
.PP
See also normalExit(), exitStatus(), and processExited().
.SH "void QProcess::kill () const\fC [slot]\fR"
Terminates the process. This is not a safe way to end a process since the process will not be able to do any cleanup. tryTerminate() is safer, but processes can ignore a tryTerminate().
.PP
The nice way to end a process and to be sure that it is finished, is to do something like this:
.PP
.nf
.br
process->tryTerminate();
.br
QTimer::singleShot( 5000, process, SLOT( kill() ) );
.br
.fi
.PP
This tries to terminate the process the nice way. If the process is still running after 5 seconds, it terminates the process the hard way. The timeout should be chosen depending on the time the process needs to do all its cleanup: use a higher value if the process is likely to do a lot of computation or I/O on cleanup.
.PP
The slot returns immediately: it does not wait until the process has finished. When the process terminates, the processExited() signal is emitted.
.PP
See also tryTerminate() and processExited().
.SH "bool QProcess::launch ( const QByteArray & buf, QStringList * env = 0 )\fC [virtual]\fR"
Runs the process and writes the data \fIbuf\fR to the process's standard input. If all the data is written to standard input, standard input is closed. The command is searched for in the path for executable programs; you can also use an absolute path in the command itself.
.PP
If \fIenv\fR is null, then the process is started with the same environment as the starting process. If \fIenv\fR is non-null, then the values in the string list are interpreted as environment setttings of the form \fCkey=value\fR and the process is started with these environment settings. For convenience, there is a small exception to this rule under Unix: if \fIenv\fR does not contain any settings for the environment variable \fCLD_LIBRARY_PATH\fR, then this variable is inherited from the starting process.
.PP
Returns TRUE if the process could be started; otherwise returns FALSE.
.PP
Note that you should not use the slots writeToStdin() and closeStdin() on processes started with launch(), since the result is not well-defined. If you need these slots, use start() instead.
.PP
The process may or may not read the \fIbuf\fR data sent to its standard input.
.PP
You can call this function even when a process that was started with this instance is still running. Be aware that if you do this the standard input of the process that was launched first will be closed, with any pending data being deleted, and the process will be left to run out of your control. Similarly, if the process could not be started the standard input will be closed and the pending data deleted. (On operating systems that have zombie processes, Qt will also wait() on the old process.)
.PP
The object emits the signal launchFinished() when this function call is finished. If the start was successful, this signal is emitted after all the data has been written to standard input. If the start failed, then this signal is emitted immediately.
.PP
See also start() and launchFinished().
.SH "bool QProcess::launch ( const QString & buf, QStringList * env = 0 )\fC [virtual]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
The data \fIbuf\fR is written to standard input with writeToStdin() using the QString::local8Bit() representation of the strings.
.SH "void QProcess::launchFinished ()\fC [signal]\fR"
This signal is emitted when the process was started with launch(). If the start was successful, this signal is emitted after all the data has been written to standard input. If the start failed, then this signal is emitted immediately.
.PP
This signal is especially useful if you want to know when you can safely delete the QProcess object when you are not interested in reading from standard output or standard error.
.PP
See also launch() and QObject::deleteLater().
.SH "bool QProcess::normalExit () const"
Returns TRUE if the process has exited normally; otherwise returns FALSE. This implies that this function returns FALSE if the process is still running.
.PP
See also isRunning(), exitStatus(), and processExited().
.SH "void QProcess::processExited ()\fC [signal]\fR"
This signal is emitted when the process has exited.
.PP
See also isRunning(), normalExit(), exitStatus(), start(), and launch().
.PP
Example: process/process.cpp.
.SH "PID QProcess::processIdentifier ()"
Returns platform dependent information about the process. This can be used together with platform specific system calls.
.PP
Under Unix the return value is the PID of the process, or -1 if no process belongs to this object.
.PP
Under Windows it is a pointer to the \fCPROCESS_INFORMATION\fR struct, or 0 if no process is belongs to this object.
.PP
Use of this function's return value is likely to be non-portable.
.SH "QString QProcess::readLineStderr ()\fC [virtual]\fR"
Reads a line of text from standard error, excluding any trailing newline or carriage return characters and returns it. Returns QString::null if canReadLineStderr() returns FALSE.
.PP
By default, the text is interpreted to be in Latin-1 encoding. If you need other codecs, you can set a different codec with QTextCodec::setCodecForCStrings().
.PP
See also canReadLineStderr(), readyReadStderr(), readStderr(), and readLineStdout().
.SH "QString QProcess::readLineStdout ()\fC [virtual]\fR"
Reads a line of text from standard output, excluding any trailing newline or carriage return characters, and returns it. Returns QString::null if canReadLineStdout() returns FALSE.
.PP
By default, the text is interpreted to be in Latin-1 encoding. If you need other codecs, you can set a different codec with QTextCodec::setCodecForCStrings().
.PP
See also canReadLineStdout(), readyReadStdout(), readStdout(), and readLineStderr().
.SH "QByteArray QProcess::readStderr ()\fC [virtual]\fR"
Reads the data that the process has written to standard error. When new data is written to standard error, the class emits the signal readyReadStderr().
.PP
If there is no data to read, this function returns a QByteArray of size 0: it does not wait until there is something to read.
.PP
See also readyReadStderr(), readLineStderr(), readStdout(), and writeToStdin().
.SH "QByteArray QProcess::readStdout ()\fC [virtual]\fR"
Reads the data that the process has written to standard output. When new data is written to standard output, the class emits the signal readyReadStdout().
.PP
If there is no data to read, this function returns a QByteArray of size 0: it does not wait until there is something to read.
.PP
See also readyReadStdout(), readLineStdout(), readStderr(), and writeToStdin().
.PP
Example: process/process.cpp.
.SH "void QProcess::readyReadStderr ()\fC [signal]\fR"
This signal is emitted when the process has written data to standard error. You can read the data with readStderr().
.PP
Note that this signal is only emitted when there is new data and not when there is old, but unread data. In the slot connected to this signal, you should always read everything that is available at that moment to make sure that you don't lose any data.
.PP
See also readStderr(), readLineStderr(), and readyReadStdout().
.SH "void QProcess::readyReadStdout ()\fC [signal]\fR"
This signal is emitted when the process has written data to standard output. You can read the data with readStdout().
.PP
Note that this signal is only emitted when there is new data and not when there is old, but unread data. In the slot connected to this signal, you should always read everything that is available at that moment to make sure that you don't lose any data.
.PP
See also readStdout(), readLineStdout(), and readyReadStderr().
.PP
Example: process/process.cpp.
.SH "void QProcess::setArguments ( const QStringList & args )\fC [virtual]\fR"
Sets \fIargs\fR as the arguments for the process. The first element in the list is the command to be executed. The other elements in the list are the arguments to the command. Any previous arguments are deleted.
.PP
QProcess does not perform argument substitutions; for example, if you specify "*" or "$DISPLAY", these values are passed to the process literally. If you want to have the same behavior as the shell provides, you must do the substitutions yourself; i.e. instead of specifying a "*" you must specify the list of all the filenames in the current directory, and instead of "$DISPLAY" you must specify the value of the environment variable \fCDISPLAY\fR.
.PP
Note for Windows users. The standard Windows shells, e.g. \fCcommand.com\fR and \fCcmd.exe\fR, do not perform file globbing, i.e. they do not convert a "*" on the command line into a list of files in the current directory. For this reason most Windows applications implement their own file globbing, and as a result of this, specifying an argument of "*" for a Windows application is likely to result in the application performing a file glob and ending up with a list of filenames.
.PP
See also arguments() and addArgument().
.SH "void QProcess::setCommunication ( int commFlags )"
Sets \fIcommFlags\fR as the communication required with the process.
.PP
\fIcommFlags\fR is a bitwise OR of the flags defined by the Communication enum.
.PP
The default is \fCStdin|Stdout|Stderr\fR.
.PP
See also communication().
.SH "void QProcess::setWorkingDirectory ( const QDir & dir )\fC [virtual]\fR"
Sets \fIdir\fR as the working directory for processes. This does not affect running processes; only processes that are started afterwards are affected.
.PP
Setting the working directory is especially useful for processes that try to access files with relative paths.
.PP
See also workingDirectory() and start().
.SH "bool QProcess::start ( QStringList * env = 0 )\fC [virtual]\fR"
Tries to run a process for the command and arguments that were specified with setArguments(), addArgument() or that were specified in the constructor. The command is searched for in the path for executable programs; you can also use an absolute path in the command itself.
.PP
If \fIenv\fR is null, then the process is started with the same environment as the starting process. If \fIenv\fR is non-null, then the values in the stringlist are interpreted as environment setttings of the form \fCkey=value\fR and the process is started in these environment settings. For convenience, there is a small exception to this rule: under Unix, if \fIenv\fR does not contain any settings for the environment variable \fCLD_LIBRARY_PATH\fR, then this variable is inherited from the starting process; under Windows the same applies for the environment variable \fCPATH\fR.
.PP
Returns TRUE if the process could be started; otherwise returns FALSE.
.PP
You can write data to the process's standard input with writeToStdin(). You can close standard input with closeStdin() and you can terminate the process with tryTerminate(), or with kill().
.PP
You can call this function even if you've used this instance to create a another process which is still running. In such cases, QProcess closes the old process's standard input and deletes pending data, i.e., you lose all control over the old process, but the old process is not terminated. This applies also if the process could not be started. (On operating systems that have zombie processes, Qt will also wait() on the old process.)
.PP
See also launch() and closeStdin().
.PP
Example: process/process.cpp.
.SH "void QProcess::tryTerminate () const\fC [slot]\fR"
Asks the process to terminate. Processes can ignore this if they wish. If you want to be certain that the process really terminates, you can use kill() instead.
.PP
The slot returns immediately: it does not wait until the process has finished. When the process terminates, the processExited() signal is emitted.
.PP
See also kill() and processExited().
.SH "QDir QProcess::workingDirectory () const"
Returns the working directory that was set with setWorkingDirectory(), or the current directory if none has been explicitly set.
.PP
See also setWorkingDirectory() and QDir::current().
.SH "void QProcess::writeToStdin ( const QByteArray & buf )\fC [virtual slot]\fR"
Writes the data \fIbuf\fR to the process's standard input. The process may or may not read this data.
.PP
This function always returns immediately. The data you pass to writeToStdin() is copied into an internal memory buffer in QProcess, and when control goes back to the event loop, QProcess will starting transferring data from this buffer to the running process. Sometimes the data will be transferred in several payloads, depending on how much data is read at a time by the process itself. When QProcess has transferred all the data from its memory buffer to the running process, it emits wroteToStdin().
.PP
Note that some operating systems use a buffer to transfer the data. As a result, wroteToStdin() may be emitted before the running process has actually read all the data.
.PP
See also wroteToStdin(), closeStdin(), readStdout(), and readStderr().
.SH "void QProcess::writeToStdin ( const QString & buf )\fC [virtual slot]\fR"
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
The string \fIbuf\fR is handled as text using the QString::local8Bit() representation.
.SH "void QProcess::wroteToStdin ()\fC [signal]\fR"
This signal is emitted if the data sent to standard input (via writeToStdin()) was actually written to the process. This does not imply that the process really read the data, since this class only detects when it was able to write the data to the operating system. But it is now safe to close standard input without losing pending data.
.PP
See also writeToStdin() and closeStdin().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqprocess.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqprocess.3qt) and the Qt
version (3.3.8).
|