我的程序
void sysmoniDialog::readFromStdout()
{
// Read and process the data.
// Bear in mind that the data might be output in chunks.
/*
QFile file("dir.txt");
if(!file.open(IO_WriteOnly))
{
//ioError(in,tr("cannot open file dir.txt for reading));
QMessageBox *box = new QMessageBox("Dir Results","cannot open file dir.txt for writing.",QMessageBox::Information,QMessageBox::Ok,0,0);
box->show();
exit(0);
}
QStringList lines;
lines.append(process->readStdout());
QTextStream stream( &file );
for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
stream << *it << "\n";
file.close();
*/
textEdit1->append(p->readStdout());
}
void sysmoniDialog::GetProState()
{
p = new QProcess(this);
p->addArgument("more");
p->addArgument("pro.txt");
p->start();
connect( p, SIGNAL(readyReadStdout()),this, SLOT(readFromStdout()) );
/*
QStringList command;
command.append(tr("more"));
command += " pro.txt";
process->start(&command);
*/
if (p->normalExit())
{
QMessageBox *box = new QMessageBox("Dir Results","If you see this message,the process dir is suceed.",QMessageBox::Information,QMessageBox::Ok,0,0);
box->show();
}
else
{
QMessageBox *box = new QMessageBox("Dir Results","If you see this message,the process dir is failed.",QMessageBox::Information,QMessageBox::Ok,0,0);
box->show();
}
delete p;
p = 0;
}
执行时,QProcess p执行时,是抱错的!
各位请指点一下!
[ 此贴被XChinux在2008-07-18 13:45重新编辑 ]