Results 1 to 9 of 9

Thread: QTimerEvent

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

    Default QTimerEvent

    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

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 284 Times in 279 Posts

    Default Re: QTimerEvent

    How to understand "TimerEvent works as a task" ?

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

    Default Re: QTimerEvent

    if i have many graph and each graph work with a timerEvent, is these graphs are running concurrently?

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 284 Times in 279 Posts

    Default Re: QTimerEvent

    No because You have one event loop and events are handled sequentially.

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

    Default Re: QTimerEvent

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

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,332
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    317
    Thanked 871 Times in 858 Posts

    Default Re: QTimerEvent

    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.

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

    Default Re: QTimerEvent

    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.

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

    Default Re: QTimerEvent

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

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

    Default Re: QTimerEvent

    I resolved the problem by using QMutex between replot and QwtPlotCurve::drawLines. It's ok now.

Similar Threads

  1. Replies: 9
    Last Post: 22nd February 2011, 20:19
  2. Replies: 7
    Last Post: 26th July 2008, 13:24

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
  •  
Qt is a trademark of The Qt Company.