Click here to Skip to main content
15,860,859 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 ;

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

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

}
Posted
Updated 19-Dec-13 3:47am
v2

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...
 
Share this answer
 
Comments
Coder_Jack 19-Dec-13 9:49am    
I improved the question. Could you please check it again. Thanks.
Form the documentation[^], it looks you should use:
C++
QProcess myProcess;
myProcess.start("pcd_viewer", QStringList() << "Results.pcd");
 
Share this answer
 
Comments
Coder_Jack 19-Dec-13 9:50am    
I improved the question. Could you please check it again. Thanks.
CPallini 19-Dec-13 10:03am    
Are you sure you are providing the right parameters (process path, etc)?
See this Stack Overflow question, for suggestions on error handling:
http://stackoverflow.com/questions/10799130/what-is-the-reason-for-qprocess-error-status-5
Coder_Jack 19-Dec-13 10:44am    
You are great Mr. CPallini :) Thank you. It just worked. Inspired by you
CPallini 19-Dec-13 10:47am    
You are welcome.
I got the solution. This works in ubuntu 12.04.
C++
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");
}
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900