PDA

View Full Version : QTimerEvent



hassinoss
9th July 2014, 12:43
Hi,

I am trying to develop an application for viewing channels from a core. visualization is done according boards, each board contains graphs. for each graph there is a timerevent. My question is TimerEvent works as a task if iput startTimer (0)?

Thank you in advance

Lesiok
9th July 2014, 12:59
How to understand "TimerEvent works as a task" ?

hassinoss
9th July 2014, 13:08
if i have many graph and each graph work with a timerEvent, is these graphs are running concurrently?

Lesiok
9th July 2014, 13:46
No because You have one event loop and events are handled sequentially.

anda_skoa
9th July 2014, 13:47
The timers will trigger whenever their timeout runs out, however, all timers within the same thread can obviously only process their timeout sequentially.

It is easier if you don't think in low level timer events but in QTimer instances.
Each QTimer triggers the slot connected to its timeout() signal, but of course only one of these slot can be executed at a single given time.

If you need parallel execution of these slots, you need threads.

Cheers,
_

d_stranz
10th July 2014, 02:57
If you need parallel execution of these slots, you need threads.

But if the OP is trying to update several GUI elements simultaneously, this can't be done with threads. All GUI elements must live in the main thread, and events there are handled sequentially.

hassinoss
10th July 2014, 12:25
Hi,

Now i'm making Qthread with each graph, but when i lunch trace in qwt plot,k i have a crash memory in this line :

QwtPlotCurve::drawLines(painter,xMap, yMap, canvasRect, m_ListSegment[iIndex].iFirst,m_ListSegment[iIndex].iLast);

When i make Sleep(10) there is not a crash memory.

Please help me, thank you in advance.

anda_skoa
10th July 2014, 13:24
Make sure the painting code is not executed by any other thread than the main thread or that the painter is created on a QImage and not on a QWidget or QPixmap

In the first case also make sure that the data is not accessed in write mode by the thread while it is being read by the main thread.

Cheers,
_

hassinoss
12th July 2014, 15:32
I resolved the problem by using QMutex between replot and QwtPlotCurve::drawLines. It's ok now.