Hi,
I want to use QwtDial with QThread. it mean that i call setValue in the run() of QThread. but somtimes it crashes.
Please any idea?
Hi,
I want to use QwtDial with QThread. it mean that i call setValue in the run() of QThread. but somtimes it crashes.
Please any idea?
That class name sounds like a widget, only the main thread (the one executing QApplication::exec()) is allowed to work with widgets.
If setValue() is a slot then you can call it through a cross-thread signal/slot connection, i.e. doing any data processing in the worker thread and the painting in the main thread
Cheers,
_
i don't understand. This my function run :
void CSpeedoMeter::Tracer(unsigned char* pPacket)
{
while(m_bStart)
{
m_dValue = *(double*) (pPacket+m_XVoie.iPositionDataTraite);
setValue(m_dValue);
}
}
and i must call setValue() in thread.
QwtDial:setValue() is a function on the widget object that exists in the main (UI) thread (assuming the dial is visible). You cannot safely call this function directly from another thread (through a pointer to the widget for example).
QwtDial:setValue() is also declared as a slot. You can have a QObject in the other thread emit a signal that you connect to the slot in the object in the main (UI) thread.
The widget cannot exist in the secondary thread as your code snippet suggests it does.
Bookmarks