我正在尝试编写一个 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