导航:首页 > 软件知识 > qt如何打开关闭外部exe程序

qt如何打开关闭外部exe程序

发布时间:2024-12-08 23:23:03

‘壹’ qt中如何运行外部程序,QProcess类

QT中使用QProcess启用外部程序 启用外部程序,并可传参,默认第一个参数是exe路径!启动外部程序的方法有以下两种: 1、start()void QProcess::start ( const QString & program, const QStringList & arguments, OpenMode mode = ReadWrite ) Starts the program program in a new process, passing the command line arguments in arguments. The OpenMode is set to mode. QProcess will immediately enter the Starting state. If the process starts successfully,QProcess will emit started(); otherwise, error() will be emitted.Note that arguments that contain spaces are not passed to the process as separate arguments.Windows: Arguments that contain spaces are wrapped in quotes.Note: Processes are started asynchronously, which means the started() and error() signals may be delayed. Call waitForStarted() to make sure the process has started (or has failed to start) and those signals have been emitted.See also pid(), started(), and waitForStarted(). 2、使用QProcess::execute(), 不过使用此方法时程序会最阻塞直到此方法执行的程序结束后返回,这时候可使用QProcess和QThread这两个类结合使用的方法来处理,以防止在主 线程中调用而导致阻塞的情况 先从QThread继承一个类,重新实现run()函数: 答:1、使用QProcess::startDetached()方法,启动外部程序后立即返回; 2、使用QProcess::execute(),不过使用此方法时程序会最阻塞直到此方法执行的程序结束后返回,这时候可使用QProcess和QThread这两个类结合使用的方法来处理,以防止在主线程中调用而导致阻塞的情况 先从QThread继承一个类,重新实现run()函数:Quote:class MyThread : public QThread{public:void run(); };void MyThread::run(){QProcess::execute("notepad.exe");

阅读全文

与qt如何打开关闭外部exe程序相关的资料

热点内容
如何选择产品的风险 浏览:497
考研帮怎么发布自己的信息 浏览:829
发那科机器人程序行号如何选择 浏览:217
营业执照项目代理是什么 浏览:622
金桔能加工什么产品 浏览:621
四季桂盆景怎么养殖技术 浏览:728
外汇轨道交易怎么用 浏览:919
腾讯市场环境怎么样 浏览:67
河南都有哪些化妆品批发市场 浏览:253
爬天是怎么交易的 浏览:980
柴油是以什么作为产品的标号的 浏览:157
fc交易所如何筛选消息面 浏览:314
旅馆安装信息系统多少钱 浏览:419
东京证交所什么时候恢复正常交易 浏览:278
程序员一般什么时候辞职 浏览:939
天猫怎么看数据 浏览:674
怎么提升技术和意识 浏览:570
专家信息哪里维护才能收到评审 浏览:530
微信如何开通身份信息授权业务 浏览:176
滨江记账代理一般多少钱 浏览:734