PDA

View Full Version : QThread based Sniffer



hbtdtg
2nd August 2009, 07:21
Hi , I am quite a newbie to QT, but now there is a problem bugging me, I have a working sniffer code and i successfully integrate it into my QT 4.5 GUI. what i want to do is to display the sniffing result on some widgets.

Inside the sniffer, there is a while (1) loop which keeps the packet sniffer running, now this problem is ,if the sniffer portion in my QT GUI runs in command line, it will freeze the GUI because of this while (1) loop. The sniffer is working, i can see the result in Application Output.

So I found a way of using QThread to independently run the sniffer and trying to retrieve the output from the running thread and display them on my main window widget.

Please kindly advise me how can i achieve that, I have already got the sniffer and Qthread build( in some dummy function), now its just how to get the running result out of the thread and display them ....


Please help, many many many thanks

caduel
2nd August 2009, 12:23
the easiest way is to emit signals and connect those to your gui's slots. (You can also put custom events into your app's event loop, but that is a bit more work.)