導航:首頁 > 軟體知識 > 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程序相關的資料

熱點內容
胎囊2個數據是怎麼定的 瀏覽:834
括弧數據是什麼意思 瀏覽:512
運行程序怎麼打開 瀏覽:129
深圳松崗燕羅有什麼職業技術學校 瀏覽:593
全時店賣什麼產品 瀏覽:763
呈貢區哪些市場可以擺地攤 瀏覽:597
組隊發信息發哪個地方 瀏覽:945
文明6為什麼城邦沒有交易界面 瀏覽:808
如何推銷產品質量高 瀏覽:758
雲南楚雄南華農貿市場在哪裡 瀏覽:86
投標設計技術部分怎麼寫 瀏覽:342
什麼是快消品小食品5元批發代理 瀏覽:244
批發市場賣魚服務費怎麼算 瀏覽:909
遮陽產品怎麼買 瀏覽:260
生長因子運用什麼技術 瀏覽:137
想找代理炒股的去哪裡找 瀏覽:123
淘寶店鋪花費數據什麼意思 瀏覽:127
小程序額度券如何讓客戶使用 瀏覽:439
如何選擇產品的風險 瀏覽:499
考研幫怎麼發布自己的信息 瀏覽:831