如何让QIODevice
(QProcess
,特别是)的输出实时进入QTextEdit
?
答案 0 :(得分:1)
将QProcess::readyRead信号连接到一个插槽,然后使用QProcess::readAllStandardOutput从QProcess读取,并使用QTextEdit::append将文本写入QTextEdit。
答案 1 :(得分:0)
写自己的班级!
部首:
class MyProcess : public QProcess
{
Q_OBJECT
...
protected:
virtual qint64 readData( char * data, qint64 maxlen );
...
};
来源:
qint64 MyProcess::readData( char * data, qint64 maxlen )
{
qint64 return_value = QProcess::readData(data,maxlen);
QString str(QByteArray(data,return_value));
// write out to QTextEdit
return return_value;
}