[問題] 想請問QT中呼叫外部程式的用法

看板C_and_CPP作者 (小饅)時間15年前 (2010/10/23 12:15), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
遇到的問題: (題意請描述清楚) 我想寫出一個按鈕按下可以呼叫出一個編譯好的.exe檔,我使用了connect,但是在SLOT那邊不知該怎麼寫 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) Linux 有問題的code: (請善用置底文標色功能) #include <QApplication> #include <QProcess> #include <QThread> #include <QPushButton> class MyThread : public QThread { public slots: void run(); }; void MyThread::run() { QProcess::execute("PATH"); } int main(int argc, char *argv[]) { QApplication app(argc, argv); MyThread *thread=new MyThread; thread->start(); QPushButton *hello=new QPushButton("Hello world!"); QObject::connect( hello, SIGNAL( clicked() ), thread, SLOT(run())) ; hello->show(); return app.exec(); } 補充說明: 請問一下這樣thread那邊該如何改寫才是正確的呢? 謝謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.212.209

10/23 13:31, , 1F
QProcess需要兩個參數,一個檔案路徑一個參數
10/23 13:31, 1F

10/23 13:31, , 2F
10/23 13:31, 2F

10/24 00:18, , 3F
+ Q_OBJECT
10/24 00:18, 3F
文章代碼(AID): #1Cmc5krR (C_and_CPP)