QProcess.write to python脚本失败

QProcess.write to python脚本失败,python,qprocess,Python,Qprocess,我使用qt4qprocess在新的QThread中运行一个python3.4脚本。我想在脚本仍在运行时输入一些内容。但每次我编写时,程序都意外地完成了,python脚本仍在后台运行。不知道为什么 开始部分: process = new QProcess; QObject::connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(outlogs())); process->setProcessChannelMode(QProce

我使用qt4qprocess在新的QThread中运行一个python3.4脚本。我想在脚本仍在运行时输入一些内容。但每次我编写时,程序都意外地完成了,python脚本仍在后台运行。不知道为什么 开始部分:

process = new QProcess;
QObject::connect(process,SIGNAL(readyReadStandardOutput()),this,SLOT(outlogs()));
process->setProcessChannelMode(QProcess::MergedChannels);
process->start("python3 -i -u /home/circleone/Desktop/test.py",QProcess::Unbuffered | QProcess::ReadWrite);
if (!process->waitForStarted())
    exit(1);
写部分:

QByteArray a=str.toAscii();
int b=strlen(a);
process->write(a,b);          //it failed in this line
process->closeWriteChannel();
process->waitForBytesWritten();
process->waitForReadyRead();
读取输出部分:

QString resultstr = process->readAllStandardOutput();
emit returnResult(resultstr);
python脚本:

import threading
import time
import sys
import os

class Test(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)

    def run(self):
        global strtest
    while True:
        test = input()
        print(test)
        strtest=test
        time.sleep(0.5)

if __name__ == '__main__':
    global strtest
    strtest=''
    thread = Test()
    thread.start()
    while True:
        if(strtest == 'exit'):
            print('quit')
            os.abort()
        time.sleep(0.5)

如果有任何输出和错误,请发布输出和错误…实际上没有任何输出有应用程序输出:启动/home/circleone/build Test Desktop调试/Test。。。进程启动程序意外完成/home/circleone/build Test桌面调试/测试崩溃