qprocess

Launch and write to terminal in Qt

时间秒杀一切 提交于 2019-12-08 07:58:23
问题 I am coding in linux using Qt. I understand that with popen or QProcess I can launch terminal from my program, but how do I write into to it? I google around people are suggesting fork() and pipe(). My purpose is to do an ICMP ping with the terminal, and stop when ping successfully. I made it with popen, but I couldn't stop the ping process thus my program won't run. 回答1: You don't write anything to terminal because there's no terminal. You pass name of a program to run and its arguments as

QProcess causes memory leak

不羁岁月 提交于 2019-12-08 04:13:46
问题 I'm building a C++/Qt5.1 app which uses QProcess to launch another program, then wait for the result. Every time I run this code, valgrind says memory is lost on line 2 (the start line). QProcess command(this); command.start(commandpath, myParameters); if (command.waitForStarted(waitToStart)) { command.write(myStdIn.toLatin1()); command.closeWriteChannel(); if (command.waitForFinished(waitToFinish)) { myStdOut = command.readAllStandardOutput(); myStdErr = command.readAllStandardError(); } }

QProcess with 'cmd' command does not result in command-line window

落花浮王杯 提交于 2019-12-08 04:11:00
问题 I am porting code from MinGW to MSVC2013/MSVC2015 and found a problem. QProcess process; QString program = "cmd.exe"; QStringList arguments = QStringList() << "/K" << "python.exe"; process.startDetached(program, arguments); When I use MinGW, this code results in command-line window. But when I use MSVC2013 or MSVC2015, the same code results in cmd-process running in background without any windows. Are there any ways to make command-line window appear? 回答1: The problem was connected with

QProcess with 'cmd' command does not result in command-line window

…衆ロ難τιáo~ 提交于 2019-12-07 22:44:24
I am porting code from MinGW to MSVC2013/MSVC2015 and found a problem. QProcess process; QString program = "cmd.exe"; QStringList arguments = QStringList() << "/K" << "python.exe"; process.startDetached(program, arguments); When I use MinGW, this code results in command-line window. But when I use MSVC2013 or MSVC2015, the same code results in cmd-process running in background without any windows. Are there any ways to make command-line window appear? The problem was connected with msvc2015, not with Qt5.8.0. There is the way to escape it. The idea is to use CREATE_NEW_CONSOLE flag. #include

Run ffmpeg on Terminal MacOS [closed]

醉酒当歌 提交于 2019-12-07 15:11:35
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm rather new to MacOS and I cannot find it easy to working with Terminal to get ffmpeg run properly as I have on Window. I have got ffmpeg binary from http://ffmpegmac.net and I try running the executable in Terminal, it tells that the command not found ? The only way I can run it by now is using command :

Error while connecting lambda function to QProcess::error

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 10:08:31
问题 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 " << error; }); process.start("MyProgram"); process.waitForFinished(); } But I get strange error: error: no matching function for call to 'Updater::connect(QProcess* [unresolved overloaded function type], Updater::start()::)' }); What I do wrong here? The code executes

Qt: can't launch Windows console with QProcess

蓝咒 提交于 2019-12-07 08:58:35
问题 QProcess simply doesn't display the black console window. This is the code I use: QProcess*p=new QProcess(this); p->start("cmd.exe"); Replacing cmd.exe with calc.exe successfully launches the calculator. 回答1: Try this instead: QProcess::startDetached("cmd.exe"); 来源: https://stackoverflow.com/questions/10363918/qt-cant-launch-windows-console-with-qprocess

How do I read from QProcess?

丶灬走出姿态 提交于 2019-12-07 07:46:17
问题 I have this simple C++ program: int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QProcess ps; QByteArray ba; ps.start("ls J:"); ba = ps.readAllStandardOutput(); char *someData = ba.data(); cout << "Testing QProcess ..." << endl; cout << someData << endl; cout << "done!" << endl; return a.exec(); } The output is: Testing QProcess ... done! If I run "ls J:" from Windows cmd it works. What am I missing? 回答1: Use QIODevice::waitForReadyRead() in a loop, and only after that

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

北慕城南 提交于 2019-12-07 02:10:10
问题 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] << " >> " << "\"/tmp/testing.txt\""); procWriteProject.start("qconf -sprj " + projectList[0] + " >> " + "/tmp/test_settings"); Will either of those work? Is there a better way? 回答1: QProcess procWriteProject; procWriteProject.setStandardOutputFile("/tmp/test_settings.txt")

Using QProcess.finished() in Python 3 and PyQt

一曲冷凌霜 提交于 2019-12-06 06:13:24
How can I use the QProcess.finished() to call a different Python3 script. Here's the script I call: #!/usr/bin/python from PyQt4.QtGui import QApplication from childcontrolgui import childcontrolgui def main(): import sys app = QApplication(sys.argv) wnd = childcontrolgui() wnd.show() sys.exit(app.exec_()) if __name__ == '__main__': main() To call the script I use the code as seen here def properties(self): command="python3 ../GUI/main.py" self.process=QProcess() self.process.finished.connect(self.onFinished) self.process.startDetached(command) def onFinished(self, exitCode, exitStatus): self