android - Qt/C++: interrupt QProcess arbitrarily with button (simulate ^c) -


so need make qt application (with gui) executes "adb logcat" command (it's log keeps being generated until ^c pressed). need gui button make process stop , pass output text browser. code use qprocess output:

qprocess process; process.start("adb logcat"); process.waitforfinished(-1); qbytearray logcatout = process.readallstandardoutput(); ui->devicesoutput->settext(logcatout); 

thank you

process.waitforfinished(-1);

would prevent program of being executed further, till process "adb" has finished. gui frozen.

  1. you should define qprocess process class variable. use qprocess *process; instead of creating on stack. (best practice qobject derivates)

  2. declare slot handles clicked-signal of button.

  3. call process->terminate() in slot.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -