Hello,

I am relatively new to Qt, but so far I am enjoying it! I only hope someone has an idea what may be going wrong with my program...

I am using QProcess to start a process and capture its output. I am running WIN32 console applications, and in some cases, it works fine. For example, I can capture output from ipconfig, or ping, or whatever other command similar to those that I may want to capture.

The issue that I am having right now, however, is that not all programs are capable of being captured. I have access to another binary that if I execute by itself, I get output like I normally would. I can redirect it to a file using typical command line switches (> in this case)... but if I execute it using my program, it exits with a NormalStatus but with a Failed to Start code (added an if statement to check it in the ProcessedFinished function, not shown below), without any output. Several other binaries are the same way...

I have verified that it is not a permission issue, or a path issue for that matter. It isn't failing to start the process, it is producing the failed to start QProcess code in the ProcessFinished funtion but not before.

I don't know where to go from here, as I don't see anyone else having this problem if I search on the web. I am hoping someone here may be able to assist.

The section of code that I am having an issue with is below:

Qt Code:
  1. FlashDialog::FlashDialog(QWidget *parent):QDialog(parent)
  2. {
  3. setupUi(this);
  4. connect(okButton,SIGNAL(clicked()),this,SLOT(close()));
  5. connect(&proc,SIGNAL(readyReadStandardOutput()),this,SLOT(readFromStdout()));
  6. connect(&proc,SIGNAL(readyReadStandardError()),this,SLOT(readFromStdErr()));
  7. connect(&proc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(processError(QProcess::ProcessError)));
  8. connect(&proc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(processFinished(int,QProcess::ExitStatus)));
  9.  
  10. }
  11. void FlashDialog::setFilePath(QString filePath)
  12. {
  13. proc.start(filePath);
  14. }
  15.  
  16. void FlashDialog::readFromStdout()
  17. {
  18. QByteArray newData=proc.readAllStandardOutput();
  19. QString text=statusView->toPlainText() + QString::fromLocal8Bit(newData);
  20. statusView->setPlainText(text);
  21.  
  22. }
  23. void FlashDialog::readFromStdErr()
  24. {
  25. QByteArray newData=proc.readAllStandardError();
  26. QString text=statusView->toPlainText() + QString::fromLocal8Bit(newData);
  27. statusView->setPlainText(text);
  28.  
  29. }
  30.  
  31. void FlashDialog::processFinished(int exitCode,QProcess::ExitStatus exitStatus)
  32. {
  33. if(exitStatus==QProcess::CrashExit)
  34. {
  35. statusView->append("Program Crashed";);
  36. }
  37. }
  38.  
  39. void FlashDialog::enableOkButton()
  40. {
  41.  
  42. }
  43. void FlashDialog::processError(QProcess::ProcessError error)
  44. {
  45. if(error==QProcess::FailedToStart)
  46. {
  47. statusView->append("Failed to start";);
  48. }
  49. }
To copy to clipboard, switch view to plain text mode 

I am under somewhat of a time crunch, so any suggestions or help are greatly appreciated!