[英]Running and killing processes in QT C++ via button press
我試圖編寫一個GUI,當按下一個按鈕時,它將啟動或停止一個進程。 目前,我的代碼甚至都不會啟動該過程,而我堅持這樣做的原因。 單擊該按鈕,文本更改,但是該過程沒有執行,並且沒有錯誤消息發生。 這是QMainWindow對象中按鈕槽的代碼:
void clickedSlot(){
QString s = "Record";
//switch between record and stop
if(s!=((QPushButton*)sender())->text()){
((QPushButton*)sender())->setText("Record");
process->kill();
process->waitForFinished();
delete process;
}else{
((QPushButton*)sender())->setText("Stop");
process = new QProcess(this);
QString executable = "./record";
process->start(executable);
process->waitForStarted();
}
};
對於為什么QProcess無法啟動以及如何停止之后的任何幫助,將不勝感激。 我在代碼頂部確實有一個#include
問題可能出在(不是)您正在啟動的可執行路徑中。 請確保以下內容重試:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.