⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qprocess.3qt

📁 linux下GUI编程工具qt的在线连接帮助手册
💻 3QT
📖 第 1 页 / 共 2 页
字号:
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..PPThe process is not started. You must call start() or launch() to start the process..PPSee 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..PPThe process is not started. You must call start() or launch() to start the process..PPSee also setArguments(), addArgument() and start()..SH "QProcess::~QProcess ()"Destroys the class..PPIf the process is running, it is NOT terminated! Standard input, standard output and standard error of the process are closed..PPYou can connect the destroyed() signal to the kill() slot, if you want the process to be terminated automatically when the class is destroyed..PPSee 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..PPThe first element in the list of arguments is the command to be executed; the following elements are the arguments to the command..PPSee also arguments() and setArguments()..PPExample: 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()..PPSee 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..PPSee 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..PPSee also readLineStdout() and canReadLineStderr()..SH "void QProcess::clearArguments ()"Clears the list of arguments that are set for the process..PPSee also setArguments() and addArgument()..SH "void QProcess::closeStdin ()\fC [virtual slot]\fR"Closes standard input of the process..PPThis function also deletes pending data that is not written to standard input yet..PPSee also wroteToStdin()..SH "int QProcess::communication () const"Returns the communication required with the process..PPSee 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..PPIf 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..PPSee also normalExit() and processExited()..SH "bool QProcess::isRunning () const"Returns TRUE if the process is running, otherwise FALSE..PPSee 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 cleanup. tryTerminate() is a safer way to do it, but processes might ignore a tryTerminate()..PPThe nice way to end a process and to be sure that it is finished, is doing something like this:.PP.nf.br    process->tryTerminate();.br    QTimer::singleShot( 5000, process, SLOT( kill() ) );.br.fi.PPThis 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 the cleanup: use a higher value if the process is likely to do heavy computation on cleanup..PPThe slot returns immediately: it does not wait until the process has finished. When the process really exited, the signal processExited() is emitted..PPSee 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..PPIf \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 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..PPReturns TRUE if the process could be started; otherwise returns FALSE..PPNote 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..PPThe process may or may not read the \fIbuf\fR data sent to its standard input..PPYou 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.).PPThe 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..PPSee 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..PPThe 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..PPSee 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..PPSee also isRunning(), exitStatus() and processExited()..SH "void QProcess::processExited ()\fC [signal]\fR"This signal is emitted when the process has exited..PPSee also isRunning(), normalExit(), exitStatus(), start() and launch()..PPExample: process/process.cpp..SH "PID QProcess::processIdentifier ()"Returns platform dependent information about the process. This can be used together with platform specific system calls..PPUnder Unix the return value is the PID of the process, or -1 if no process is belonging to this object..PPUnder Windows it is a pointer to the \fCPROCESS_INFORMATION\fR struct, or 0 if no process is belonging to this object..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..PPSee 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..PPSee 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()..PPIf there is no data to read, this function returns a QByteArray of size 0: it does not wait until there is something to read..PPSee 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()..PPIf there is no data to read, this function returns a QByteArray of size 0: it does not wait until there is something to read..PPSee also readyReadStdout(), readLineStdout(), readStderr() and writeToStdin()..PPExample: 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()..PPNote 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..PPSee 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()..PPNote 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..PPSee also readStdout(), readLineStdout() and readyReadStderr()..PPExample: 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..PPSee 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 between the flags defined in Communication..PPThe default is \fCStdin|Stdout|Stderr\fR..PPSee also communication()..SH "void QProcess::setWorkingDirectory ( const QDir & dir )\fC [virtual]\fR"Sets \fIdir\fR as the working directory for a process. This does not affect running processes; only processes that are started afterwards are affected..PPSetting the working directory is especially useful for processes that try to access files with relative filenames..PPSee 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 in the path for executable programs; you can also use an absolute path to the command..PPIf \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 enverionment varialbe \fCPATH\fR..PPReturns TRUE if the process could be started, otherwise FALSE..PPYou can write data to standard input of the process with writeToStdin(), you can close standard input with closeStdin() and you can terminate the process tryTerminate() resp. kill()..PPYou can call this function even when there already is a running process in this object. In this case, QProcess closes standard input of the old process and deletes pending data, i.e., you loose all control over that process, but the 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.).PPSee also launch() and closeStdin()..PPExample: process/process.cpp..SH "void QProcess::tryTerminate () const\fC [slot]\fR"Asks the process to terminate. Processes can ignore this wish. If you want to be sure that the process really terminates, you must use kill() instead..PPThe slot returns immediately: it does not wait until the process has finished. When the process really exited, the signal processExited() is emitted..PPSee 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 set..PPSee also setWorkingDirectory() and QDir::current()..SH "void QProcess::writeToStdin ( const QByteArray & buf )\fC [virtual slot]\fR"Writes the data \fIbuf\fR to the standard input of the process. The process may or may not read this data..PPThis function returns immediately; the QProcess class might write the data at a later point (you have to enter the event loop for that). When all the data is written to the process, the signal wroteToStdin() is emitted. This does not mean that the process really read the data, since this class only detects when it was able to write the data to the operating system..PPSee 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..PPThe 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..PPSee also writeToStdin() and closeStdin()..SH "SEE ALSO".BR http://doc.trolltech.com/qprocess.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf 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..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qprocess.3qt) and the Qtversion (3.0.0).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -