qprocess

launch GUI app from QProcess

感情迁移 提交于 2019-12-24 10:28:26
问题 I want to launch GUI app using QProcess. process.start() return immediately without showing GUI app window. I also tried CONFIG += console .It didn't work. QProcess process; process.setEnvironment(QProcess::systemEnvironment()); process.start("pkexec --user root ",QStringList()<<QString("apt-get install xyz")); process.waitForFinished(); process.close(); 回答1: Try process.start("pkexec", QStringList() << "--user" << "root" << "apt-get" << "install" << "xyz"); 来源: https://stackoverflow.com

QProcess fails with Qt 5.10.1 and Windows 10

一笑奈何 提交于 2019-12-24 09:55:22
问题 I recently compiled Qt 5.10.1 statically (mingw32) and the routine below now fails to work. I modified the code to include the full path for windows cmd "c:\windows\system32\cmd.exe" but that still doesn't work. Attempted with Windows 7 & 10. The code below works fine with Qt 5.6. Its job is to open a Windows terminal. Similar code to open a console in macOS and Linux works. NOTE: This behavior is a bug introduced in Qt 5.8 see: https://bugreports.qt.io/browse/QTBUG-57687 QString commstr =

What is the reason for QProcess error status 5?

我只是一个虾纸丫 提交于 2019-12-23 03:01:12
问题 i have multiple threads running the following QProcess. Randomly they fail with error state 5. The Qt docs do not give any more details. Has anyone a clue what that error could come from? Thank you very much. extCmd = new QProcess(this); QString cmd = "/usr/bin/php"; QStringList argStr; argStr << "/bin/sleep" << "10"; // changed to ever working command extCmd->start(cmd, args); bool suc = extCmd->waitForFinished(-1); if (!suc) { qDebug() << "finishing failed error=" << extCmd.error() <<

What is the reason for QProcess error status 5?

浪子不回头ぞ 提交于 2019-12-23 03:01:09
问题 i have multiple threads running the following QProcess. Randomly they fail with error state 5. The Qt docs do not give any more details. Has anyone a clue what that error could come from? Thank you very much. extCmd = new QProcess(this); QString cmd = "/usr/bin/php"; QStringList argStr; argStr << "/bin/sleep" << "10"; // changed to ever working command extCmd->start(cmd, args); bool suc = extCmd->waitForFinished(-1); if (!suc) { qDebug() << "finishing failed error=" << extCmd.error() <<

Qt: QProcess to call terminal + script

房东的猫 提交于 2019-12-22 18:39:11
问题 I am having real trouble with the use of QProcess, I've looked at several locations to use it, but everytime I use it my program freezes, or it just doesn't do what I want it to do. What I want to do from my GUI application is the following: Change directory to /Users/Tim/etc etc. From there I need to call gnuplot and load a script into it. What I'd normally would do in a terminal window is the following: > cd /Users/Tim/... > /opt/local/bin/gnuplot barchartscript.txt At the moment I'm using

Qprocess messes my linux command up (i think). how to fix? [duplicate]

99封情书 提交于 2019-12-22 11:15:56
问题 This question already has answers here : Command working in terminal, but not via QProcess (3 answers) Closed 6 years ago . I need to force my c++ QT4 application to read results from a linux command. I am trying to use Qprocess but as soon as my command gets complicated it get messed somehow (just guessing) and does not work. Here i try to make for yu a small example: QProcess process; command = "ls -l | grep a | sort"; qDebug() << "Execute command -> "+command; process.start( command );

When using pyqt on Windows, what does the QProcess.pid() result represent?

余生颓废 提交于 2019-12-22 10:23:38
问题 The documentation for QProcess.pid() says: Returns the native process identifier for the running process, if available. If no process is currently running, 0 is returned. What does this mean? This code is used to explain my confusion. I am using Python 2.7.9, PyQt 4 and Windows 7: import sys, os, time from PyQt4.QtCore import * from PyQt4.QtGui import * class testLaunch(QWidget): def __init__(self): QWidget.__init__(self) self.process = QProcess(self) self.process.start('calc') self.process

Change PATH environment variable for cmd.exe with QProcessEnvironment

喜夏-厌秋 提交于 2019-12-20 07:34:08
问题 I want to start cmd.exe from a Qt app with a specific PATH set. I insert "Path" in QProcessEnvironment and set that environment to QProcess. Then I startDetached "cmd". On the command prompt, the path is the same as the from the calling app, not what I just set. Did I miss something? I use Qt 5.2.0 with mingw and Qt-creator 3.0.0 on windows 8.1.s QProcess process(this); QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("Path", "MyPath"); process

Terminate an ongoing QProcess that is running inside a QThread? [duplicate]

蹲街弑〆低调 提交于 2019-12-20 05:31:47
问题 This question already has answers here : Ensuring QProcess termination on termination of its parent QThread (2 answers) Closed last year . how to terminate an ongoing QProcess that is running inside a QThread and gets deleted by another QThread? I even inserted a QMutex extCmdProcessLock, which should avoid the destruction of the DbManager before the extCmdProcess could finish or timeout. I get a segmentation fault on "waitForStarted" if another thread calls delete on DbManager. I cannot use

How to detect when ssh connection (over a QProcess) has finished?

放肆的年华 提交于 2019-12-20 04:04:15
问题 I am running an ssh tunnel from an application using a QProcess : QProcess* process = new QProcess(); process->start("ssh", QStringList()<<"-L"<<"27017:localhost:27017"<<"example.com"); So far it works great, the only problem being that there is no way for me to see when the port has actually been created. When I run the command on a shell, it takes about 10 seconds to connect to the remote host after which the forwarded port is ready for usage. How do I detect it from my application? EDIT: