Qt进程被自动杀死

时间:2018-07-05 13:42:31

标签: qt

单击按钮时,需要启动两个进程( p pr )。但是不幸的是我的第二个进程(pr)自动被杀死。函数 OutLan 永远不会被调用。

QString lancn;
void MainWindow::on_lineEditPathSet(QString inputpath)
{ 

    QString parameters = " " + settings.value("save_nmix").toString() + " " + settings.value("save_norm_method").toString() + " " + settings.value("save_thresh_value").toString() + " " + settings.value("save_oos_thresh").toString() + " " + flag;
    QString cmd = "test.exe " + inputpath + parameters;

    if (p)
    {
      p->setEnvironment( QProcess::systemEnvironment() );
      p->setProcessChannelMode( QProcess::SeparateChannels );
      p->start(cmd);
      p->waitForStarted();
      connect( p, SIGNAL(readyReadStandardOutput()), this, SLOT(OutTable()) );
      connect( p, SIGNAL(readyReadStandardError()), this, SLOT(ErrConsole()));
    }

    QMessageBox msgBox(this);
    msgBox.setWindowTitle("Launching Testing Process");
    msgBox.setText("Testing process is being initialized.\n\nIt may take some time.\n\nPlease wait.");
    msgBox.setIcon(QMessageBox::Information);
    msgBox.exec();
    if(lang_method.compare("ConvoNet")==0)
    {
        QProcess pr;

        QStringList params;
        params.append("test.py");
        params.append(inputpath);
        pr.start("python", params);
        pr.waitForStarted();
        connect( &pr, SIGNAL(readyReadStandardOutput()), this, SLOT(OutLan()) );

    }
}

    void MainWindow::OutLan()
    {
        QProcess *p = dynamic_cast<QProcess *>( sender() );
        lancn=p->readLine();
    }

输出:

QProcess:在进程(“ python”)仍在运行时被破坏。

请告诉我为什么进程( pr )被杀死?

0 个答案:

没有答案