how to use terminal commmands on qt -


i qt project , want compile , run few c++ codes on qt. have written following code compile c++ file. don't know how check if program compiled properly. if once program has compiled, how run in terminal?

the revised code:

void mainwindow::on_actioncomplile_triggered() {     qprocess compile;     compile.setworkingdirectory("/home");     compile.setreadchannel(qprocess::standardoutput);     compile.setprocesschannelmode(qprocess::mergedchannels);     qtextstream out(stdout);      compile.start("gnome-terminal");     compile.write("ls"); //these lines not printed.        compile.waitforreadyread();     compile.waitforfinished(-1);      qbytearray msg = compile.readall();     out << msg.data() << endl; } 

i found solution:

void mainwindow::on_actioncomplile_triggered() {     qprocess compile;     compile.setworkingdirectory("/home/royal");     compile.setreadchannel(qprocess::standardoutput);     compile.setprocesschannelmode(qprocess::mergedchannels);     qtextstream out(stdout);      compile.start("g++",qstringlist() << "tes.cpp" << "-o" << "test");     compile.waitforfinished(-1);      qbytearray msg = compile.readallstandardoutput();     if(msg.isempty())     {         qdebug() << "successful";     }     else qdebug() << "failed"; } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -