在我的Qt应用中运行另一个可执行文件 [英] Run another executable in my Qt app

查看:741
本文介绍了在我的Qt应用中运行另一个可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了两个Qt应用程序。一个是主要的,另一个是侧面的。

I wrote two Qt applications. One is the main and the other is a side way.

我正在运行Linux。
我读了 QProcess 所以我写了这段代码:

I am running Linux. I read about QProcess so I wrote this code:

 QApplication a(argc, argv);
    MainWindow w;

    w.show();
    QProcess P(&w);
    QString programPath;
    programPath=
    "/Documents/Qt/test1-build-desktop-Qt_4_8_1_in_PATH__System__Release/test1";
    P.start(programPath);

    return a.exec();

但是,没有任何反应,只有我的主要应用程式( w )运行。

However, nothing happens and just my main app (w) runs.

我的错误是什么?
请帮助我。

What is my fault? Please help me.

推荐答案

我的错误在可执行文件的路径。

My fault was in path to executable.

我编辑它变得很简单,让它工作。

I edit it vary simple and got it work.

QApplication a(argc, argv);
MainWindow w;
w.show();
QProcess P(&w);
QString programPath;
programPath=
    "/home/erfan/Documents/Qt/test1-build-desktop- Qt_4_8_1_in_PATH__System__Release/test1";
P.start(programPath);
return a.exec();

并且正常工作。

方法是将可执行文件直接放在根目录中:

Another way is to put the executable directly in root:


(/ somthings) / p>

(/ somthings)

这篇关于在我的Qt应用中运行另一个可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆