application.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "application.h"
  2. #include <QProcess>
  3. #include <QDebug>
  4. Application::Application(QObject *parent) :
  5. QObject(parent),
  6. m_process(new QProcess(this))
  7. {
  8. connect(m_process,
  9. SIGNAL(finished(int, QProcess::ExitStatus)),
  10. SLOT(finished(int, QProcess::ExitStatus)));
  11. }
  12. QString Application::appName() const
  13. {
  14. return m_AppName;
  15. }
  16. void Application::setAppName(const QString &appName)
  17. {
  18. m_AppName = appName;
  19. }
  20. QString Application::stdERR() const
  21. {
  22. return m_stdERR;
  23. }
  24. void Application::setstdERR(const QString &stdERR)
  25. {
  26. m_stdERR = stdERR;
  27. }
  28. QString Application::stdOUT() const
  29. {
  30. return m_stdOUT;
  31. }
  32. void Application::setstdOUT(const QString &stdOUT)
  33. {
  34. m_stdOUT = stdOUT;
  35. }
  36. QString Application::arguments() const
  37. {
  38. return m_Arguments;
  39. }
  40. void Application::setArguments(const QString &arguments)
  41. {
  42. m_Arguments = arguments;
  43. }
  44. QString Application::launchScriptGetSTDOUT()
  45. {
  46. m_process->start(m_AppName + " " + m_Arguments);
  47. // m_process->waitForStarted(-1);
  48. return "Start requested";
  49. qDebug() << "launching application" << m_AppName << "\n with the Argument of \n" + m_Arguments ;
  50. }
  51. void Application::finished(int exitCode, QProcess::ExitStatus status)
  52. {
  53. m_stdOUT = QString(m_process->readAllStandardOutput());
  54. m_stdERR = QString(m_process->readAllStandardError());
  55. emit this->appFinished();
  56. }