qprocess

reading and writing to QProcess in Qt Console Application

你。 提交于 2019-11-28 11:17:51
问题 Noted: this appears to be a specific issue question but hopefully it can be edited for all to related to I need to interact with a QProcess object. The Problem: I am not getting any output from QProcess after calling QProcess:write(input) More Info: Going through the doc pages led me to create an example below: I have a script requesting user input, and finally displaying and appropriate message based on the user input. Testing: After adding a "log" feature to my script for testing, the

Qt create Link between folders

安稳与你 提交于 2019-11-28 05:19:46
问题 I have to build a small dialog that creates a symbolic link to a folder. In windows I would use mklink /D command. Is there a possibility to create such links in Qt? I have only seen QFile creating links between files and that they need to end with .lnk (http://qt-project.org/doc/qt-4.8/qfile.html#link) QDir on the other hand does not provide anything. Any suggestions? Best regards, Richard 回答1: Is there a possibility to create such links in Qt? Yes, it is, but only on Unix. Unfortunately,

Piping (or command chaining) with QProcess

穿精又带淫゛_ 提交于 2019-11-27 23:34:11
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 QProcess; process->start(cmd); process->waitForBytesWritten(); process->waitForFinished(); qDebug() << process->readAll(); The problem is in pipe ("|"), and process returs nothing. If there is no ("|"), like "cat file" everything is ok. I tried smth. like "cat file \\| grep string", "cat file \| grep string" but result is the same. If I copy the command and run it in bash everything is ok. QString::toAscii().data() and other

read QProcess output to string

ⅰ亾dé卋堺 提交于 2019-11-27 20:35:48
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" << "-c" << "public" << "10.18.32.52" << ".1.3.6.1.4.1.30966.1.2.1.1.1.5.10"; status=pingProcess.execute(exec, params); pingProcess.close(); } This outputs the following. SNMPv2-SMI::enterprises.30966.1.2.1.1.1.5.10 = STRING: "0.1" I want to take(read) this output as string. I searched for this and I cant find the solution. Thanks in advance. Shf Did you try QByteArray QProcess::readAllStandardOutput()

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

China☆狼群 提交于 2019-11-27 16:08:40
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. No you can't get a signal when you use startDetached because you have no object. startDetached is a static function and when you call it the process is started directly without creating a QProcess object. Therefore, even if there was a signal you would not be able to connect it to anything since you have no object to connect from. If you want a signal you should create a QProcess object and then call start on it. You will

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

不问归期 提交于 2019-11-27 15:13:13
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 start() and the ":/..." notation, but I don't seem to get the process running. Is there anything I am missing? Should it work like this? Does the binary need to be set as executable? Background: I am writing a tool which uses Git and I don't want to require the end-user to install Git manually. (Trying this on Mac OS X, BTW.) Update: I am using the

Start a process using QProcess

南楼画角 提交于 2019-11-27 14:13:17
问题 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 ? 回答1: may be code below will help you: QProcess *process = new QProcess(this); QString program = "explorer.exe"; QString folder = "C:\\"; process->start(program, QStringList() << folder); I think you are trying to execute program that doesn't consists

How to get STDOUT from a QProcess?

喜欢而已 提交于 2019-11-27 08:02:20
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 reading the data until EOF reached QByteArray data; while(process.waitForReadyRead()) data.append(process.readAll()); // Output the data qDebug(data.data()); qDebug("Done!"); What I am expecting is to see the output from the program printed to the debug console, but all I see is: Done! I know that: The program is started fine, because the message at the

get all running processes info using QProcess

霸气de小男生 提交于 2019-11-27 06:57:40
问题 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 create C:\ProcessList.txt file contains all running processes in the system. i wonder how can i run it using QProcess and take its output to a variable. it seems every time i try to run it and read nothing happens: QString program = "C:\\WINDOWS\

read QProcess output to string

不羁岁月 提交于 2019-11-26 20:24:59
问题 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" << "-c" << "public" << "10.18.32.52" << ".1.3.6.1.4.1.30966.1.2.1.1.1.5.10"; status=pingProcess.execute(exec, params); pingProcess.close(); } This outputs the following. SNMPv2-SMI::enterprises.30966.1.2.1.1.1.5.10 = STRING: "0.1" I want to take(read) this output as string. I searched for this and I