-4

I have created a main Window with one Pushbutton in QT and when I try to run an additional small program when the Pushbutton is clicked, it doesn't work. I have the following code:

void MainWindow::on_pushButton_clicked()
{
    QProcess *process = new QProcess(this);
    process->start("/home/helloworld.out");
}

I am working with Linux. Any ideas what could happend? Thank you in advance.

m7913d
  • 8,353
  • 7
  • 20
  • 47
J.Blanco
  • 1
  • 1
  • _"Any ideas what could happend?"_ - Based on your description it sounds like your kajigger is out of alignment. – Captain Obvlious Jul 26 '17 at 16:10
  • Do you see any error messages? Can you check the status of process? [see the error enum http://doc.qt.io/qt-5/qprocess.html] – Paul Floyd Jul 26 '17 at 16:15
  • Do you have permission to execute some file in the `/home` folder ?, usually with the default user you can only access `/home/$USER` – eyllanesc Jul 26 '17 at 17:15
  • Please try to create a [mcve]. Is it a problem related to a bad signal/slot connection, i.e. `on_pushButton_clicked` or a `QProcess` problem? – m7913d Jul 26 '17 at 19:21
  • I posted an [MCVE](http://stackoverflow.com/help/mcve) for `QProcess` some days ago: [SO: Creating QT Application as GUI for existing console-based application on windows](https://stackoverflow.com/a/45209503/7478597) – Scheff's Cat Jul 27 '17 at 06:18

1 Answers1

0

You are starting your process and then promptly returning. If you are not planning on connecting any signals from the QProcess you could just statically allocate it to save yourself from using deleteLater.

Try something like this.

void MainWindow::on_pushButton_clicked()
{
    QProcess process;;

    process.start("~/helloworld.out");
    process.waitForStarted();
    process.waitForFinished();
    process.close();
}

I'll step out on a limb and suggest maybe you did not mean /home/helloworld.out but ~/helloworld.out. In any case check the path exists as well.

konakid
  • 55
  • 1
  • 7