Guest User

Untitled

a guest
Mar 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. InterProcess::InterProcess(QObject *parent) : QProcess(parent)
  2. {
  3. process = new QProcess(this);
  4. process->start(myChildApp);
  5. process->waitForStarted();
  6. process->setCurrentWriteChannel(QProcess::StandardOutput);
  7. process->write("Test");
  8.  
  9. connect( process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)) );
  10. connect( process, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()) );
  11. connect( process, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()) );
  12.  
  13. QByteArray InterProcess::read()
  14. {
  15. QByteArray readBuffer = process->readAllStandardOutput();
  16. return readBuffer;
  17. }
  18.  
  19. void InterProcess::error( QProcess::ProcessError error )
  20. {
  21. qDebug() << "Error!";
  22. qDebug() << error;
  23. }
  24.  
  25. void InterProcess::readyReadStandardError()
  26. {
  27. qDebug() << "Ready to read error.";
  28. qDebug() << process->readAllStandardError();
  29. }
  30.  
  31. void InterProcess::readyReadStandardOutput()
  32. {
  33. qDebug() << "The output:";
  34. QByteArray readBuffer = process->readAllStandardOutput();
  35. qDebug() << readBuffer;
  36. }
  37.  
  38. InterProcess::InterProcess(QObject *parent) : QProcess(parent)
  39. {
  40. process = new QProcess();
  41. process->setCurrentReadChannel(QProcess::StandardOutput);
  42.  
  43. connect( process, SIGNAL(readyRead()), this, SLOT(readyReadStandardOutput()));
  44. connect( process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(error(QProcess::ProcessError)) );
  45. connect( process, SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()) );
  46. connect( process, SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()) );
  47.  
  48. process->waitForReadyRead(5000);
  49. }
  50.  
  51. void InterProcess::readyReadStandardError()
  52. {
  53. qDebug() << "Ready to read error.";
  54. qDebug() << process->readAllStandardError();
  55. setText("REady error");
  56. }
  57.  
  58. void InterProcess::readyReadStandardOutput()
  59. {
  60. setMessage("2");
  61. qDebug() << "The output:";
  62. QByteArray readBuffer = process->readAllStandardOutput();
  63. qDebug() << readBuffer;
  64. }
  65. void InterProcess::error( QProcess::ProcessError error )
  66. {
  67. qDebug() << "Error!";
  68. qDebug() << error;
  69. setText(QString(error));
  70. }
Add Comment
Please, Sign In to add comment