views:

17

answers:

1

Here is what I need to do.

-I receive log data through a udp connection -I stack relevant data in a qlist -I have a timer running in the main thread that, on timeout, unstacks this data, updates some arrays then calls widget->update -The widget re-implements paintEvent and uses these arrays to draw charts.

What would be the best way to do this in order to not have any bugs.

this task is basically three processes, two of which are done in the main thread

1-I have a qthread that asks for and receives log through udp packets. This thread also stacks the data in a qlist.

2-I have a qtimer that on timeout, unstacks these events, preps the chart arrays and then calls update

3-I have a reimplementation of the paintEvent method on that widget.

I have mutexes to synchronise and protect data. Is this a bad way of doing it? Some suggestion for a "SAFE" way of doing would be appreciated.

On a side note the paintEvent is dont on a customwidget which is inside my mainwindow. I do have a second thread (concurent function) that periodically refreshes some data then emits a signal to update label fields that are outside the custom widget but inside the mainwindow. could this have a bad side effect on everything?

+2  A: 

Overall, I think you've got the foundation for a solid program. The only suggestion I might make is to move task #2 to its own thread also. You can take advantage of the fact that you can draw on a QImage outside of the main UI thread to prep the chart arrays in a different thread. This would remove the biggest potential bottleneck to UI responsiveness from your code, and wouldn't add much more to the complexity, since you already have threads in your program. The updating on QTimer could work there just as well. When a new image is ready, you could send it either via signal or via posted event to your UI, which could then copy the image and update its display.

Caleb Huitt - cjhuitt
ok I am going to accept this answer but if/when I have further questions would you be available for contact?
yan bellavance
@yan: I generally check new questions and replies to me on this site every couple of days.
Caleb Huitt - cjhuitt