qprocess

Cannot execute echo command in QProcess

柔情痞子 提交于 2019-12-18 09:22:01
问题 I want to launch a SCPI command in my device using netcat utility under Ubuntu 10.04 LTS with Qt. My code looks like: env = "echo TRIG | nc 192.168.1.100 23 -q1"; process1.execute(env); process1.waitForFinished(1000); This command does not return any data but simply triggers the data acquisition. If using terminal with same "echo TRIG | nc 192.168.1.100 23 -q1" command, everything works fine. From Qt, it does not work. The debug output is "TRIG | nc 10.0.3.250 23 -q1" ... so without an "echo"

Set Environment Variables for startDetached() QProcess

我只是一个虾纸丫 提交于 2019-12-18 09:21:25
问题 In Qt4, there is QProcess::setProcessEnvironment() for setting Env variables for the newly spawn process. However, QProcess::startDetached() is a static member function, so setProcessEnvironment() doesn't apply. How does one set Env variables for a detached process in Qt? 回答1: It is a known old bug: http://bugreports.qt-project.org/browse/QTBUG-2284. You need to overload startDetached function to support your own environment. Take a look at Qt sources to see how to do that: http://code.qt.io

Piping (or command chaining) with QProcess

血红的双手。 提交于 2019-12-17 16:33:46
问题 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.

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

本小妞迷上赌 提交于 2019-12-17 14:52:37
问题 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. 回答1: 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

Starting QProcess from QThread [duplicate]

心已入冬 提交于 2019-12-13 05:51:56
问题 This question already has answers here : Ensuring QProcess termination on termination of its parent QThread (2 answers) Closed last year . I was using QThreads in Qt where my need is to launch a command-line executable from within a Qt thread and run the same within the thread's context. I have used the below mentioned code for the same which seems to be running fine. However, I wanted to know if this kind of usage is permitted since we are launching a QProcess from within a QThread. void

QProcess that will outlive the parent for updating

南楼画角 提交于 2019-12-13 05:33:41
问题 There have been several posts regarding this, but I've not experienced the same. I'm running QT under Windows and trying to start an installer that will overwrite my app. I've been able to do this in C#, but being new to QT, I've not been able to find the "secret sauce" that allows the the launched process to outlive the app. I've tried newing the process because someone mentioned that if they do that and don't delete the QProcess, then it was living on after the launcher app went away. I

Starting 7zip from QProcess gives error “cannot find archive”

时间秒杀一切 提交于 2019-12-13 04:47:38
问题 i am working on an application made with Qt5 that downloads a .zip-file to a temporary directory and extracts the .zip-file to a specified directory. I already managed to download the .zip-file and now I'm trying to extract it using 7zip. I use QProcess to start 7Zip. Here the file structure of my Qt-build-kit-thingy: build-ExtractTest-Desktop_Qt_5_3_MSVC2013_64bit-Debug 7za.exe build ExtractTest.exe Here is the code I use for starting the Process: // assemble extraction command QString

How to communicate Qt applications two-way

江枫思渺然 提交于 2019-12-13 03:51:09
问题 I want to create two-way communicate beetwen my Qt Apps. I want to use QProcess to do this. I'm calling sucesfully child app from root app and sending test data without any erro, but I can't recive any data in child app. I'll be gratefull for any help. I'm using Qt 4.7.1. Below my test code: Root app: InterProcess::InterProcess(QObject *parent) : QProcess(parent) { process = new QProcess(this); process->start(myChildApp); process->waitForStarted(); process->setCurrentWriteChannel(QProcess:

Bring QProcess window to front (running Qt Assistant)

佐手、 提交于 2019-12-13 03:38:03
问题 My Qt application starts a QProcess that runs Qt Assistant. I am using Linux (Ubuntu/Neon/KDE) but I want the Qt application to run on Windows and other Linux distributions as well. Now I need a function that allows to bring the Assistant main window to front at the desktop. I could not find a solution doing this using the QProcess object. Also I could not find a way to do this via Qt Assistant remote control. How can I do this in a portable way? 回答1: If all you need is showing qhc help files

How to destroy QProcess when it finishes and the class than contaed the slot

£可爱£侵袭症+ 提交于 2019-12-11 19:39:33
问题 I start a QProcess in member function of a class but that object (Pdf object below) will soon get destroyed after creating the process. I obviously want the slot function to be available and called when QProcess finishes. I pass QProcess pointer so when it finishes, it will destroy it as well. But actually it doesn't really is destroyed when it finishes. void PDf::createPDF() { PdfSymlink * pdfSymlink = new PdfSymlink( fileName, linkName, myProcess ); connect(myProcess, SIGNAL(finished(int)),