user interface - Asynchronously Run Console Output and GUI in Qt -


i working on building gui around console application. able click button run console app , show console output inside of gui itself. how might accomplish this? working in linux.

you try qprocess. provides qt interface launching external processes, reading i/o , waiting, or not, on completion.

for purpose, sounds want process run asynchronously, code might :

myprocessstarter.h :

#include <qobject> #include <qprocess> #include <qdebug>   class myprocessstarter : public qobject {     q_object public:     myprocessstarter() : qobject() {};     void startprocess(); private slots:     void readstandardoutput(); private:     qprocess *myprocess; }; 

main.cpp:

#include "myprocessstarter.h"  void myprocessstarter::startprocess() {     qstring program = "dir";     qstringlist arguments;     // add arguments want passed      myprocess = new qprocess(this);     connect(myprocess, signal(readyreadstandardoutput()), this, slot(readstandardoutput()));     myprocess->start(program, arguments); }  void myprocessstarter::readstandardoutput() {     qbytearray processoutput;     processoutput = myprocess->readallstandardoutput();      qdebug() << "output " << qstring(processoutput); }  void main(int argc, char** argv) {     myprocessstarter s;     s.startprocess(); } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -