J'essaie de lire et d'écrire à partir d'un processus q maintenant. J'ai fait un petit programme de test qui prend l'entrée et la réaffiche sur l'écran en boucle. Voici mon code de QtQProcess lire et écrire
QString path = "./test";
tcd = new QProcess(this);
QStringList args;
args << "";
tcd->start(path,args);
if(!tcd->waitForStarted(3000))
{
stdoutput->append("<h1><font color=red>There was a problem starting the software, please try running the program again.</font></h1>");
}
tcd->write("hello\n");
tcd->write("hello\n");
tcd->write("hello\n");
tcd->write("hello\n");
//tcd->write("quit\n");
QObject::connect(tcd, SIGNAL(readyReadStandardOutput()), this, SLOT(appendTextBox()));
Cela ne fonctionnera pas à moins que j'envoie cette dernière commande quit (qui met fin à mon programme de test).
Voici mon ordre de lecture:
void TCD2_GUI::appendTextBox(){
stdoutput->append("new output available: \n");
QByteArray newData = tcd->readAllStandardOutput();
stdoutput->append(QString::fromLocal8Bit(newData));
}
si j'envoie Quit, je vais obtenir toutes les sorties du programme à la fois, y compris tout ce que je l'ai envoyé.
Qu'est-ce que je fais mal ici?
selon la demande, voici le code du programme:
int main(int argC[], char* argV[]){
printf("Welcome!\n");
char* input = malloc(160);
gets(input);
while(strcmp(input,"quit") != 0)
{
printf("Got input %s\n", input);
gets(input);
}
}
oui, mais je suis signal de capture, donc je ne pense pas que si la matière. Mais peut-être que j'ai une mauvaise compréhension de cela. Peu importe, je mets un tcd-> waitForBytesWritten(); dans mon code, et toujours rien .. Edit: J'ai un bouton qui envoie une entrée dans mon code, donc c'est après le signal est lancé, toujours rien. –