I wanted to use the python interpreter in a QT C++ program,
I tried to open a python console using QProcess:
QProcess shell; // this is declared in the class .h file
shell.start("python");
connect(&shell,SIGNAL(readyRead()),SLOT(shellOutput()));
shell.write("print 'hello!'\n");
But I didn’t catch any outputs, where did I get it wrong, or is there a better way doing this?
I wrote a very minimalistic program that does what you expected. Below is the code:
mainwindow.hpp
main.cpp
Implementation notes:
QProces::waitFor...().QProcess::closeWriteChannel().QProcessis quite helpful.These things together show a motivating
hello!when the pushbutton is pressed.