Results 1 to 4 of 4

Thread: Updating QwtPlot from QThread

  1. #1
    Join Date
    Apr 2011
    Location
    Japan
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Updating QwtPlot from QThread

    Hi everybody, this is my first post to this forum. I'm noob to both Qt and C++.

    I'm trying to implement a gui for my hardware which takes analog data by a PCI AD card and processes all those data and visualize by using QwtPlot. Besides it does some other control by using a PCI DA and PCI Counter boards.

    What I'm doing now in visualization part is, acquiring the data by a QThread then showing them as QwtPlotCurve objects in the main thread. Since I have too much data (getting 12 channels simultaneously) I have 12 curve objects. Storing the data in a QVector<QVector<double>> which is 13 x 2000 (may change) and updating all those curve data in the main thread takes too much of cpu time. This makes the gui less responsive (pressing the stop button responses after 5 seconds or sometimes never)

    What I want to do is, updating the QwtPlotCurves in a new QThread like the other QThread acquiring data. But when I tried this, I could not reach the Qwt objects from inside of the thread.

    I've checked both the forum and the Qt4 book I have. The way to communicate between threads is using signal/slot, I know. But when I use this way, main thread will still be busy when the slot is called to update the curves.

    I'm asking some ideas, how to overcome this? Most probably I'm missing something since I'm totally a noob. All your comments are welcome.
    Thanks

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Updating QwtPlot from QThread

    Stick to one thread and call processEvents in the loop.
    That will make your gui responsive again.

  3. #3
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Updating QwtPlot from QThread

    I'm having the exact same situation here. Real-Time-Data-Acquisition-Oscilloscope !

    You should leave the acquisition in a separate thread with higher priority. To reduce the load for the gui thread you could prepare a QwtSeriesData and pass it through a signal to your gui thread. There you use a QwtPlotDirectPainter to plot only the data that just arrived and avoid replotting everything.

    If that is still not fast enough, qwt provides the QwtWeedingCurveFitter. With it you can subsample your data to make plotting faster. http://www.qtcentre.org/threads/2843...ng-application

    Let me know if you need more details,

    HIH

    Johannes
    Last edited by JohannesMunk; 5th April 2011 at 15:16.

  4. #4
    Join Date
    Apr 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Updating QwtPlot from QThread

    Quote Originally Posted by JohannesMunk View Post
    I'm having the exact same situation here. Real-Time-Data-Acquisition-Oscilloscope !

    You should leave the acquisition in a separate thread with higher priority. To reduce the load for the gui thread you could prepare a QwtSeriesData and pass it through a signal to your gui thread. There you use a QwtPlotDirectPainter to plot only the data that just arrived and avoid replotting everything.

    If that is still not fast enough, qwt provides the QwtWeedingCurveFitter. With it you can subsample your data to make plotting faster. http://www.qtcentre.org/threads/2843...ng-application

    Let me know if you need more details,

    HIH

    Johannes
    Hi Johannes,
    I am having exactly the same issue, can you provide more details please
    Thanks,Lam

Similar Threads

  1. Replies: 0
    Last Post: 15th May 2009, 16:12
  2. Replies: 6
    Last Post: 14th May 2009, 13:02
  3. Replies: 4
    Last Post: 26th June 2008, 19:41
  4. Spawn a QThread in another QThread
    By david.corinex in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2007, 13:54
  5. Replies: 15
    Last Post: 8th May 2007, 12:46

Tags for this Thread

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.