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
Post a Comment