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
7
votes
2 answers

Error while connecting lambda function to QProcess::error

In following code I want to connect lambda function to QProcess::error signal: void Updater::start() { QProcess process; QObject::connect(&process, &QProcess::error, [=] (QProcess::ProcessError error) { qWarning() << "error " <<…
folibis
  • 12,048
  • 6
  • 54
  • 97
7
votes
1 answer

Do I get a finished slot if I start QProcess using startDetached

Do I get a finished signal if I start a QProcess using startDetached()? I'm trying to start a process, but I need to be able to get an event when the process has terminated.
Hao Wooi Lim
7
votes
1 answer

How can I direct the output of a QProcess to a file?

I want to have the output of qconf redirected to test_settings.txt in my tmp folder. I've thought of two possibilities: QProcess procWriteProject; procWriteProject.start("qconf", QStringList() << " -sprj " << projectList[0] << " >> " <<…
nish
  • 1,008
  • 4
  • 17
  • 34
7
votes
3 answers

Qt Calling External Python Script

I am trying to write a GUI wrapper for one of my command line tools written in Python. It was suggested to me that I should use Qt. Below is my project's .cpp file: #include "v_1.h" #include…
devoidfeast
  • 829
  • 3
  • 12
  • 22
7
votes
2 answers

QProcess and shell : Destroyed while process is still running

I want to launch a shell script with Qt. QProcess process; process.start(commandLine, QStringList() << confFile); process.waitForFinished(); if(process.exitCode()!=0) { qDebug () << " Error " << process.exitCode() <<…
user2007861
  • 407
  • 3
  • 6
  • 17
6
votes
4 answers

How to start a Shell Script with QProcess?

How can I start a Shell Script using QProcess? The Shell Script has eight different commands in it, some with arguments others without. I tried to start the Shell Script with (using Ubuntu 11.10): QProcess *Prozess = new…
Streight
  • 811
  • 4
  • 15
  • 28
6
votes
2 answers

Qt - Wait for Qprocess to finish

I'm using CMD by QProcess but I have a problem. My code: QProcess process; process.start("cmd.exe"); process.write ("del f:\\b.txt\n\r"); process.waitForFinished(); process.close(); When I don't pass an argument for waitForFinished() it waits for…
6
votes
1 answer

Qt: How to catch an error with system call?

I am building a GUI application where I do a system call and call for gnuplot to run a script. Now i want to build in an error message that says when something is wrong (e.g. gnuplot is not installed or in the wrong path). So I've been thinking…
Tcanarchy
  • 760
  • 1
  • 8
  • 20
6
votes
3 answers

QProcess not executing a python script

I'm trying to execute a process in Qt (in Linux) that executes a python script and I haven't been able to make it work. This is the code: QProcess process; QString scriptFile = "../../scriptPath/script.py"; QString pyCommand = "\"python " +…
Carlos Pastor
  • 979
  • 2
  • 11
  • 26
5
votes
1 answer

Terminating QProcess in a destructor

A have a problem trying to stop my QProcess in it's parent destructor. Here is my code: AbstractProcess::~AbstractProcess() { if((m_process->state() == QProcess::Running) || (m_process->state() == QProcess::Starting)) { …
Polina Bodnar
  • 171
  • 3
  • 15
5
votes
1 answer

What's the difference between QProcess::kill() and QProcess::terminate()?

I read some documentation but it isn't clear enough to me. I know that both "end" a process and that kill() is meant to force it to end, but what is terminate() supposed to do then?
Michael
  • 1,018
  • 4
  • 14
  • 30
5
votes
1 answer

How to use QProcess write correctly?

I need a program to communicate with a subprocess that is relying on in- and output. The problem is that I am apparently not able to use QProcess correctly. The code further down should create a QProcess, start it and enter the main while loop. In…
NRiesterer
  • 95
  • 1
  • 10
5
votes
3 answers

how to get output system() command in Qt?

I use system() command in Qt. and I want to get output and show it to users. my command is: system("echo '" + rootPass.toAscii() + "' | su - root -c 'yum -y install " + packageName.toAscii() + "'"); this command can't run when I use it in QProcess…
mohsen amiri
  • 73
  • 1
  • 2
  • 7
5
votes
1 answer

QProcess fails to execute external executable

I am struggling to find a solution to my problem, but I simply have no clue how to solve it. I am creating an user-interface for some programs I made (so you can through simply pressing a button start an executable). So I thought of using qt. So I…
jj01
  • 68
  • 1
  • 7
5
votes
2 answers

Initialize QProcess to a process already running

I would like know if it's possible to create a QProcess and initialize it to a process which is already running? My application starts an other application. So if my application is abnormally closed, when it will be restarted, I would like attach…
artoon
  • 729
  • 2
  • 14
  • 41
1
2
3
44 45