QProcess退出状态和开始新状态

QProcess exit status and starting new one

我是QT新手

代码:

void MainWindow::test()
{
  ui->label->setText("it worked !");
  proc->start("c:/windows/system32/calc.exe");
}

void MainWindow::on_pushButton_clicked()
{
   proc = new QProcess();
   connect(proc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(test()));
   proc->start("c:/windows/system32/notepad.exe");
}

所以当我关闭记事本时它会启动它,计算器会启动但它会无限打开。

我的代码有什么问题?

由于您没有断开插槽,"calc.exe" 退出时它将再次启动。

即当 notepad.exe 完成时,信号会触发运行 "calc.exe" 的 test() 插槽。 "calc.exec" 结束后,同样的一系列事件再次发生。