PDA

View Full Version : Threading and plotting graph in same program.



sar_van81
9th May 2007, 05:12
Hi everyone,

Is it possible to run a thread and plotting the graph simultaneously ? i mean i have a thread which reads data every one second and based upon the datas i need to plot a graph. is this possible ?i tried this ,but was not successfull. the thread reads the datas correctly,but i cant see the graph. when i comment the thread , the graph is being displayed ?

can anybody provide suggestions or solutions for this ?

thanks in advance,

saravanan.

sar_van81
9th May 2007, 07:16
Ok, let me put the question this way:

i have any application where i'l construct a thread and monitor the data from the serial port in the thread::run() function. if there is data in the serial port i'l read it and create a qwt plot object and display the data. is this possible ?

i read in the qt docs (http://doc.trolltech.com/3.3/threads.html) that we should not create a widget inside the thread ? Is this the reason why i can't see the qwt plot widget ?

jacek
9th May 2007, 20:42
i read in the qt docs (http://doc.trolltech.com/3.3/threads.html) that we should not create a widget inside the thread ? Is this the reason why i can't see the qwt plot widget ?
Yes, if the docs say that something won't work, it won't work. In Qt you can use widgets only in the GUI thread (aka main thread).

In your situation you can use custom events to send processed data from the thread to the GUI.

http://doc.trolltech.com/3.3/qcustomevent.html