PDA

View Full Version : system() call external command, and get command resuld



cooper
14th July 2009, 02:18
hi everyone,

in my program, i need to call an external command ("dmtxread") to decode a 2D barcode. and display the result.

i can achieve above what i need by using system()

system("dmtxread /home/cz/Webcam/abc.jpg >> /home/cz/Webcam/a.txt");

as you can see, i sent result into a text file (a.txt). after that, i used QFile read the content of a.txt as a string. then, display this string.

i am just wondering is there any other way i can save the result to a buffer, or a string, directly, instead of creating a file to store the result, and read the content out.

can anyone give me a hint or suggestion, please?
thank in advance.

nish
14th July 2009, 02:30
use QProcess and read the standard output into the string.

nish
14th July 2009, 02:37
why you double post? there is no need for it. Already answered in newbie post.

cooper
14th July 2009, 03:11
why you double post? there is no need for it. Already answered in newbie post.

thanks Mr death, i just want to make sure someone will read my post :o

thanks for your reply. i will take a look QProcess

nish
14th July 2009, 03:27
dont worry.. a single topic will attract more ppl. And will have much more discussion. So never duplicate your topic.