how to redirect the console output to GUI in qt on linux platform
am doing a project called packet sniffing.which works lik etherial.it captures and display all the packet comes to host. to develop this project am working on linux platform and am using QT to develop it.just guide me am having following problems
- am able to 开发者_开发技巧display the packet info in console i wanted to redirect those packet info to my GUI. is it possible.
Sorry to not be precise, I do not have the refernce material in front of me. I recently did exactly this, it pretty straight forward. Use QProcess to lauch you packet sniffer, then create a slot to handle ReadyRead (?) signal. The ReadyRead slot can then read the stdout and stderr from the process and put the output onto the GUI.
If you are piping the std-output of an external program to your Qt program, you can use QTextStream and attach it to your stdin (see the docs).
From there you can pass the QTextStream object around your program and extract the input with QTextStream::readLine(), appending the lines to your (for example) QTextEdit.
I don't know if this will work, but you might even be able to grab the QIODevice from QTextStream::device() and then connect QIODevice::readyRead() signals to your own slots to make everything asynchronus.
精彩评论