如何在ubuntu中从qt运行外部程序? [英] How to run an external program from qt in ubuntu?

查看:397
本文介绍了如何在ubuntu中从qt运行外部程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过QT导入外部程序。我在谷歌或Qt网站上找到的所有文章和问题告诉我使用下面的代码,但它不起作用。我把它设置为一个按钮,但是当我运行代码并单击按钮它什么也没做。我该怎么办呢?





功能;



I am trying to import an external program through QT. All the article and questions I found on google or in Qt website tells me to use the code below but It doesnt work. I set it to a button but when I run the code and click on button It does nothing. How should I handle this?


Function ;

void MainWindow::on_pushButton_clicked()
{
    QString program = "pcd_viewer";
    QStringList arguments;
    arguments << "new.pcd";

    QProcess *myProcess = new QProcess(this);
    myProcess->start(program, arguments);

}

推荐答案

在我看来,你没有满足的实现:



QProcess myProcess(commandAndParameters);



myProcess.start();



有问题的API采用与您提供的不同的参数...
It seems to me that you don't have an implementation that will satisfy:

QProcess myProcess(commandAndParameters);
or
myProcess.start();

The APIs in question take different parameters from what you have provided...


形成文档 [ ^ ],看起来你应该使用:

Form the documentation[^], it looks you should use:
QProcess myProcess;
myProcess.start("pcd_viewer", QStringList() << "Results.pcd");


我得到了解决方案。这适用于ubuntu 12.04。

I got the solution. This works in ubuntu 12.04.
void MainWindow::on_pushButton_clicked()
{
    QString program = "/home/sabri/KHG/pcd_viewer";

    QStringList arguments;

    QProcess *myProcess = new QProcess(this);
    myProcess->start(program,(QStringList) arguments<<"/home/sabri/KHG/new.pcd");
}


这篇关于如何在ubuntu中从qt运行外部程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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