QProcess 使用
来源:互联网 发布:qq头像源码大全 编辑:程序博客网 时间:2024/05/29 18:20
QProcess类用于启动另一个外部应用程序,并可与之进行通信。该类的运行方式是异步的。QProcess类在外部进程拥有数据或完成时发送一个信号以通知相关的对象。
QProcess的使用模板如下:
- class XXX : public XXXX
- {
- Q_OBJECT
- …
- private slots:
- void errorHandler(QProcess::ProcessError);
- void catchOutput();
- void catchError();
- void stateMonitor(QProcess::ProcessState newState);
- void slotStarted();
- void slotFinished(int, QProcess::ExitStatus);
- …
- private:
- QProcess p;
- …
- };
- XXX::XXX(…)
- {
- …
- connect(&p, SIGNAL(started()), SLOT(slotStarted()));
- connect(&p, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotFinished(int, QProcess::ExitStatus));
- connect(&p, SIGNAL(error(QProcess::ProcessError)), SLOT(errorHandler (QProcess::ProcessError)));
- connect(&p, SIGNAL(readyReadStandardError()), SLOT(catchError()));
- connect(&p, SIGNAL(readyReadStandardOutput()), SLOT(catchOutput()));
- …
- }
- XXX:: slotStarted()
- {
- qDebug()<<”process has started”;
- }
- XXX:: slotFinished(int exitcode, QProcess::ExitStatus status)
- {
- if (exitStatus == QProcess::CrashExit) {
- …;
- } else {
- …;
- }
- }
- XXX:: errorHandler(QProcess::ProcessError error)
- {
- if (error == QProcess::FailedToStart) {
- …
- }
- else if( error == QProcess:: Crashed )
- {
- …
- }
- else if( error == QProcess:: Timedout )
- {
- …
- }
- else if( error == QProcess:: WriteError )
- {
- …
- }
- else if( error == QProcess::ReadError )
- {
- …
- }
- else if( error == QProcess:: UnknownError )
- {
- …
- }
- }
- XXX:: catchError()
- {
- QByteArray newData = process.readAllStandardError();
- …
- }
- XXX::catchOutput()
- {
- QByteArray newData = process.readAllStandardOutput();
- …
- }
0 0
- QProcess 使用
- QProcess使用感想
- 使用QProcess QThread
- QProcess使用思考
- QProcess的使用
- QProcess
- QProcess
- QProcess
- QProcess
- 使用QProcess调用另一个程序
- 使用QProcess要注意的问题(QProcess::start: Process is already running)
- 使用Qt打开外部文件,调用外部程序(QDesktopServices,QUrl ,QProcess,QProcess)
- QT中调用外部程序:QProcess的使用
- QT中调用外部程序:QProcess的使用
- QT中调用外部程序:QProcess的使用
- Qt中使用QProcess备份和恢复Mysql数据库
- QT 使用QProcess 调用外部程序并截取输出流
- QT中调用外部程序:QProcess的使用
- jenkins 部署入门
- Android 文件存储
- REST 理解
- Remove Duplicates from Sorted List
- 精益生产方式下在工程项目的成本管理
- QProcess 使用
- 20世纪中国耕地与复种指数的变化
- Random浅析以及获得随机字符串
- 黑马程序员------毕老师视频笔记第九天------面向对象(内部类)
- 小递归
- 关于“OnClickListener cannot be resolved to a type”问题
- 宝宝取名方法步骤详解
- DBMap
- linux、windows平台下如何监控mysql执行的sql语句