这是执行命令并返回输出的代码。问题是,如果我终止了 testProcess,“ping”会继续进行。我也试过
QObject *parent;
parent=new QObject;
myprocess *p;
p=new myprocess(parent);
对不起我的英语不好
测试进程.h:
class myprocess : public QProcess{
Q_OBJECT
public:
myprocess( QObject *parent = 0 );
protected slots:
void readyOut();
void readyErr();
};
testProcess.cpp 主要:
myprocess *p;
p=new myprocess;
QObject::connect(p,SIGNAL(readyReadStandardOutput()),p,SLOT(readyOut()));
QObject::connect(p,SIGNAL(readyReadStandardError()),p,SLOT(readyErr()));
p->start("ping -t www.google.com");
p->waitForFinished(60000);
delete p;