QProcess failed to start on windows when cmd prompt works.
-
HI!
When running this command from the command line prompt:
magick convert report_pages/test_0.png report_pages/test_1.png report_pages/test_2.png report_pages/test.pdfIt works perfectly. Generating a PDF from the three test png images. The location where I'm running this command is the location of the Qt Application compiled executable that I'm developing. This is a Windows application.
I want to run that same command from said Qt application.
In order to do this I use this code:
QProcess pdfmerge; pdfmerge.start(PDF_GEN_APPLICATION,arguments); bool all_good = pdfmerge.waitForFinished(); this->cmd = QString(PDF_GEN_APPLICATION) + " " + arguments.join(" ");Inside a class. PDF_GEN_APPLICATION is just a define for the string "magick convert".
As a matter a fact I took the string that I run in the CMD console from the output of printing this->cmd.When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues, I was wondering if anyone here could help me. In order to run my Qt Application I just press play in QtCreator, in case that has anything to do with it.
-
HI!
When running this command from the command line prompt:
magick convert report_pages/test_0.png report_pages/test_1.png report_pages/test_2.png report_pages/test.pdfIt works perfectly. Generating a PDF from the three test png images. The location where I'm running this command is the location of the Qt Application compiled executable that I'm developing. This is a Windows application.
I want to run that same command from said Qt application.
In order to do this I use this code:
QProcess pdfmerge; pdfmerge.start(PDF_GEN_APPLICATION,arguments); bool all_good = pdfmerge.waitForFinished(); this->cmd = QString(PDF_GEN_APPLICATION) + " " + arguments.join(" ");Inside a class. PDF_GEN_APPLICATION is just a define for the string "magick convert".
As a matter a fact I took the string that I run in the CMD console from the output of printing this->cmd.When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues, I was wondering if anyone here could help me. In order to run my Qt Application I just press play in QtCreator, in case that has anything to do with it.
@aarelovich said in QProcess failed to start on windows when cmd prompt works.:
PDF_GEN_APPLICATION is just a define for the string "magick convert".
This is wrong. The command is "magick", "convert" is a parameter and should be part of parameter list.
Also add error handling to see what happens (see https://doc.qt.io/qt-5/qprocess.html#error, https://doc.qt.io/qt-5/qprocess.html#errorOccurred). -
Tried to move convert to be the first argument. But the error is the same. QProcess Error is "Failed To Start". It was a good idea, though.
-
Tried to move convert to be the first argument. But the error is the same. QProcess Error is "Failed To Start". It was a good idea, though.
@aarelovich Try to use full path to magick, not only "magick"
-
@aarelovich Try to use full path to magick, not only "magick"
@jsulm HI! Actually I think your first suggestion fixed it. Thing is its only failing now, If I run the application from QtCreator. If I run it as a stand alone it works. It didn't work before.
So thank you!
-
@jsulm HI! Actually I think your first suggestion fixed it. Thing is its only failing now, If I run the application from QtCreator. If I run it as a stand alone it works. It didn't work before.
So thank you!
@aarelovich said in QProcess failed to start on windows when cmd prompt works.:
its only failing now, If I run the application from QtCreator
Probably it can't find "magick". If this is the case you can change PATH in the Run configuration for your project in QtCreator to add the folder containing "magick" to PATH.
-
HI!
When running this command from the command line prompt:
magick convert report_pages/test_0.png report_pages/test_1.png report_pages/test_2.png report_pages/test.pdfIt works perfectly. Generating a PDF from the three test png images. The location where I'm running this command is the location of the Qt Application compiled executable that I'm developing. This is a Windows application.
I want to run that same command from said Qt application.
In order to do this I use this code:
QProcess pdfmerge; pdfmerge.start(PDF_GEN_APPLICATION,arguments); bool all_good = pdfmerge.waitForFinished(); this->cmd = QString(PDF_GEN_APPLICATION) + " " + arguments.join(" ");Inside a class. PDF_GEN_APPLICATION is just a define for the string "magick convert".
As a matter a fact I took the string that I run in the CMD console from the output of printing this->cmd.When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues, I was wondering if anyone here could help me. In order to run my Qt Application I just press play in QtCreator, in case that has anything to do with it.
@aarelovich said in QProcess failed to start on windows when cmd prompt works.:
When I try to run the Qt Application I get the error that the process "Failed To Start". With no other clues,
First attach to
errorOccurred, as @jsulm wrote.
Second attach to read any & all standard output/error, often there is a message on standard error.