Questions tagged [qprocess]

The QProcess class, part of the Qt framework, provides a way to start external programs and to communicate with them.

The QProcess class is used to start external programs and to communicate with them.

To start a process, pass the name and command line arguments of the program you want to run as arguments to start(). Arguments are supplied as individual strings in a QStringList.

Alternatively, you can set the program to run with setProgram() and setArguments(), and then call start() or open().

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

675 questions
28
votes
2 answers

How to get STDOUT from a QProcess?

I thought I was going to get the output from a QProcess using the following code: // Start the process process.start(tr("php-cgi www/test.php"),QIODevice::ReadWrite); // Wait for it to start if(!process.waitForStarted()) return 0; // Continue…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
26
votes
4 answers

How to read QProcess output to QString?

I have a code that uses QProcess like this : int main(int argc, char *argv[]) { int status=0; QProcess pingProcess; QString ba; QString exec = "snmpget"; QStringList params; params << "-v" << "2c" <<…
sersem1
  • 466
  • 1
  • 4
  • 10
18
votes
5 answers

Piping (or command chaining) with QProcess

I'm using Qt and bash over it, need to execute something like: bash: cat file | grep string in Qt: QString cmd = "cat file | grep string"; QProcess *process = new…
Konstantin Ivanov
  • 245
  • 1
  • 3
  • 6
17
votes
1 answer

QT Open default file explorer on *nix

I have the following: QProcess *process = new QProcess(this); QString path = QDir::toNativeSeparators(QApplication::applicationPath); #if defined(Q_OS_WIN) process->start("explorer.exe", QStringList() << path); #elif…
Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
11
votes
3 answers

How to check if a program is running by its name with Qt (C++)

How to check if a program is running, by its name, with Qt (C++). Will QProcess::pid do the job? I don't know how to use it. Please suggest.
Random78952
  • 1,520
  • 4
  • 26
  • 36
10
votes
3 answers

How to execute complex linux commands in Qt?

I want to restart the computer by running a command in linux using QProcess. I have hard-coded my root password in my application. When i run the following in a terminal it works perfect: echo myPass | sudo -S shutdown -r now When i put the…
Nejat
  • 31,784
  • 12
  • 106
  • 138
10
votes
2 answers

What is the difference between QProcess::start and QProcess::startDetached?

The Qt documentation gives this explanation: QProcess::start: Starts the given program in a new process, if none is already running, passing the command line arguments in arguments. QProcess::startDetached: Starts the program program with the…
Nejat
  • 31,784
  • 12
  • 106
  • 138
8
votes
1 answer

calling Qprocess with arguments containing spaces - Windows

I am trying to call an executable with qprocess and pass some arguments which might (and most probably will) contain spaces (not all of them). The executable is a python script that has been packaged with Py2exe. The python script uses optparse to…
helplessKirk
  • 326
  • 1
  • 6
  • 16
8
votes
2 answers

get all running processes info using QProcess

few days ago i asked about how to get all running processes in the system using QProcess. i found a command line that can output all processes to a file: C:\WINDOWS\system32\wbem\wmic.exe" /OUTPUT:C:\ProcessList.txt PROCESS get Caption this will…
kaycee
  • 1,199
  • 4
  • 24
  • 42
8
votes
6 answers

Start a process using QProcess

I'm trying to start Microsoft word using QProcess as following: QString program = "WINWORD.EXE"; process->start(program); but nothing happens. winword.exe is on path (so when i type winword.exe word is openning up). Is it the right way to do so ?
kaycee
  • 115
  • 1
  • 2
  • 5
8
votes
3 answers

Launching a shell script when Button Pressed on GUI made with Qt

I have a shell script which takes backup on a remote server when executed on a touchscreen PC (Uubntu Lucid Lynx). Now I want this to be automated by making a small Button in a GUI application that is running on it. The application is built using Qt…
RicoRicochet
  • 2,249
  • 9
  • 28
  • 53
8
votes
4 answers

How do I embed a binary executable (to be executed at runtime) in a Qt program?

I'm writing a cross-platform C++ program using Qt and I want to package/embed a number of binary executables within the program. The program should be able to execute these binaries at runtime. I figured, I would need QResource and QProcess using…
jan
  • 1,160
  • 1
  • 9
  • 11
7
votes
3 answers

Child process stdin doesn't get data, sent by parent process

Parent process write string "Message\n" to child process stdin. But child process don't receive it. Where is the problem in the code? Qt 4.7.3 Parent process code: // class TestParent : public QMainWindow void TestParent::createChildProcess() { …
artyom.stv
  • 2,097
  • 1
  • 24
  • 42
7
votes
2 answers

Run a shell command via QProcess on Android Platform

I cannot run any command via QProcess on Android platform. I am using Qt library. Can anyone explain how to run shell commands from my application on Android platform ? QProcess process(); process.execute("ls"); bool finished =…
calynr
  • 1,264
  • 1
  • 11
  • 23
7
votes
6 answers

How to run a windows cmd command using Qt?

I have to run the following command using Qt, which will pop up the Git GUI window. D:\MyWork\Temp\source>git gui How do I do that? I tried the following, but it didn't work: QProcess process; process.start("git gui",QStringList() <<…
Lasitha Konara
  • 1,111
  • 3
  • 12
  • 19
1
2 3
44 45