Re: [問題] Qt QProcess用法
Try to connect readyReadStandardOutput() signal and use
readAllStandOutput() to get the output information, then.
I GUESS execute() is similar to system(<command>) call,
and the console output is already forwared to the calling process
which refers to your main program.
So that the output is printed directly in your console.
Besides, when you use start(), you have to connect error() or finished() singals
to close process, otherwise you might terminate a running process unexpectedly.
Good Luck.
※ 引述《donby (東逼)》之銘言:
: void donby::auto_open()
: {
: qDebug("auto_open");
: process->start("C:/Program Files/TTPlayer/TTPlayer.exe", command);
: ↑↑↑ 有問題的是這行
: }
: void donby::auto_close()
: {
: qDebug("auto_close");
: process->close();
: }
....
: process->start("ls", command) 改成 process->execute("ls", command)
: 雖然這樣就會正確跑出資料來了
: 但我不懂得是這兩個方法有甚麼差別?
: 表面上看起來作的事情都一樣,丟的參數也都一樣 0.0
: 而且這又衍生一個問題,除非這個外部程式結束了
: 否則我不能再繼續往下做事情
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 119.77.202.32
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章