c++ - Running external executable in Qt using QProcess -
i'm trying run external executable (code below) in qt separate process.
test.c:
#include <stdio.h> int main () { file *f; f = fopen("a.txt", "w"); fprintf(f, "1\n"); fclose(f); return 1; }
and in qt have:
qprocess* process = new qprocess(); qstring program = "/users/myuser/desktop/a.out"; process->execute(program);
i've read on differences between execute(), start(), , startdetached() , understanding want use execute() because want process running external executable finish before continuing execution in main process. i've tried 3 expecting find file a.txt containing text "1" in it, doesn't exist. or suggestions why it's not working? thanks!
check in main() -function a.txt -file exists , open before writing it.
check in qt "program" -file exists before executing it.
return different result codes main() -function , check result in qt:
qprocess *proc = new qprocess(); proc->start(program); proc->waitforfinished(); qstring result=proc->readallstandardoutput(); // check result here
Comments
Post a Comment