You can run any program from Qt5 and capture it’s standard output using the QProcess class. The official documentation with examples is here: http://doc.qt.io/qt-5/qprocess.html
So what I would do then is simply make a GUI with 2 QTextEdit widgets, one for the code and one for the compile/run output. Documentation for QTextEdit is here: http://doc.qt.io/qt-5/qtextedit.html
So the “compile and run” button would simply
- Take content of upper
QTextEditinto a temporary text file on disk. Documentation forQFileis here: http://doc.qt.io/qt-5/qfile.html - Start gcc to complie the file using
QProcessand capture the output in a string - Replace the content of the bottom
QTextEditwith the output of the compilation. - Look at return code from
QProcessto see if compilation was successful. - For successful build, simply invoke
QProcessagain, this time for the executable that was built by gcc to run the code, while appending any output to the bottom QTextEdit.
NOTE: As an exercise this is probably going to be fun and provide ample opportunity for learning, however I doubt this would be very useful on its own.
Good luck!
solved How to run gcc compiler from my qt application? [closed]