我在QProcess中啓動rsync。如果我使用QProcess::startDetached()
,我的流程運行正常(在自己的終端中),但如果我使用QProcess:start()
啓動它,則不會發生任何情況。問題似乎是QProcess無法從rsync讀取消息並將其寫入輸出窗口。QProcess在運行rsync時不顯示任何輸出
我已經在構造函數中連接了這個信號。
MainWindow::~MainWindow()
{
process = new QProcess(this);
connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput()));
}
按鈕點擊後來我打電話:
void MainWindow::onButton1Clicked()
{
process->start("rsync -a [email protected]:/path/ /rsync_folder");
//process->start("ping 10.0.0.01"); // this works for testing and I see output but not the above.
}
當rsync的開始,它打印的消息,並要求password..none它是由我的QProcess中接收,但接收到ping
消息。這裏可能有什麼錯誤?
上面的悲傷行也直接在Windows 7命令行上工作,但它似乎並沒有在QProcess中顯示任何進展。
更新
這是我如何顯示輸出。
void MainWindow::onReadyReadStandardOutput()
{
qDebug() << process->readAllStandardOutput();
}
請澄清一下,您如何知道在您的應用程序中接收到來自'ping'命令的消息?除非你通過例如'readAllStandardOutput'方法從'QProcess'中顯式讀取它們,並且將它寫入日誌或其他地方,否則它們不應該是可見的。 –
@olegandriyanove我已連接插槽,並且使用'qDebug()'輸出到輸出窗口 – zar