Results 1 to 4 of 4

Thread: QwtDial and QThread

  1. #1
    Join Date
    Dec 2013
    Location
    Jerada, Morroco
    Posts
    106
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QwtDial and QThread

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtDial and QThread

    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,
    _

  3. #3
    Join Date
    Dec 2013
    Location
    Jerada, Morroco
    Posts
    106
    Thanks
    11
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QwtDial and QThread

    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.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QwtDial and QThread

    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.

Similar Threads

  1. QwtDial label
    By lvsteenson in forum Qwt
    Replies: 1
    Last Post: 21st December 2012, 08:17
  2. Replies: 1
    Last Post: 4th October 2012, 14:49
  3. QWTDial problem
    By zaferaltug in forum Qwt
    Replies: 2
    Last Post: 20th November 2008, 15:40
  4. Can I Add two needle for QwtDial
    By validator in forum Qwt
    Replies: 4
    Last Post: 14th February 2008, 08:57
  5. QwtDial not exits
    By hiuao in forum Qwt
    Replies: 1
    Last Post: 23rd August 2007, 09:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.