diff options
author | Christian Kandeler <christian.kandeler@nokia.com> | 2012-05-23 11:00:04 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-05 06:14:28 +0200 |
commit | 046c31988e5d166a12e77bb0d9dde074a97ec74a (patch) | |
tree | 1e06a1d343e62037733d49ba25db046f5431a436 /src/corelib/io | |
parent | 0dfbb2f553287882295903fd41554eb98b54df9d (diff) |
QProcess: Add accessors for program and arguments.
Task-number: QTBUG-24550
Change-Id: I1ce26e584e39b0b58b1c9f78d8027b2479f2d92c
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qprocess.cpp | 32 | ||||
-rw-r--r-- | src/corelib/io/qprocess.h | 4 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index b75c9c1974..de8e3d4b49 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1997,14 +1997,14 @@ static QStringList parseCombinedArgString(const QString &program) /*! \overload - Starts the program \a program in a new process, if one is not already - running. \a program is a single string of text containing both the + Starts the command \a command in a new process, if one is not already + running. \a command is a single string of text containing both the program name and its arguments. The arguments are separated by one or more spaces. For example: \snippet code/src_corelib_io_qprocess.cpp 5 - The \a program string can also contain quotes, to ensure that arguments + The \a command string can also contain quotes, to ensure that arguments containing spaces are correctly supplied to the new process. For example: \snippet code/src_corelib_io_qprocess.cpp 6 @@ -2021,9 +2021,9 @@ static QStringList parseCombinedArgString(const QString &program) The OpenMode is set to \a mode. */ -void QProcess::start(const QString &program, OpenMode mode) +void QProcess::start(const QString &command, OpenMode mode) { - QStringList args = parseCombinedArgString(program); + QStringList args = parseCombinedArgString(command); if (args.isEmpty()) { Q_D(QProcess); d->processError = QProcess::FailedToStart; @@ -2039,6 +2039,28 @@ void QProcess::start(const QString &program, OpenMode mode) } /*! + Returns the program the process was last started with. + + \sa start() +*/ +QString QProcess::program() const +{ + Q_D(const QProcess); + return d->program; +} + +/*! + Returns the command line arguments the process was last started with. + + \sa start() +*/ +QStringList QProcess::arguments() const +{ + Q_D(const QProcess); + return d->arguments; +} + +/*! Attempts to terminate the process. The process may not exit as a result of calling this function (it is given diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h index 1890635eda..fe5e84ccec 100644 --- a/src/corelib/io/qprocess.h +++ b/src/corelib/io/qprocess.h @@ -133,7 +133,9 @@ public: virtual ~QProcess(); void start(const QString &program, const QStringList &arguments, OpenMode mode = ReadWrite); - void start(const QString &program, OpenMode mode = ReadWrite); + void start(const QString &command, OpenMode mode = ReadWrite); + QString program() const; + QStringList arguments() const; ProcessChannelMode readChannelMode() const; void setReadChannelMode(ProcessChannelMode mode); |