我正在尝试使用 QProcess 执行 python 控制台并在 QTextEdit 中显示控制台的内容。以下是我的主要代码:
connect(&process, SIGNAL(readyReadStandardOutput()), this, SLOT(PrintStandardOutput()));
connect(&process, SIGNAL(started()), this, SLOT(Started()));
...
void Widget::PrintStandardOutput()
{
QString stdOtuput = QString::fromLocal8Bit(process.readAllStandardOutput());
ui->textEdit_Output->append(stdOtuput);
}
void Widget::Started()
{
ui->stateLabel->setText("Process started...");
}
我曾经QProcess::start("python")启动一个新进程并QProcess::write()编写我的python代码,但我的QTextEdit中什么也看不到,顺便说一句,python进程确实是根据显示“进程启动...”的stateLabel执行的。如何让 QTextEdit 中显示的 python 输出?谢谢。