Results 1 to 6 of 6

Thread: Updating QPlot's curve with Qthread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question Updating QPlot's curve with Qthread

    Pardon me, I am new here.

    There's been similar threads with similar problem, but there's yet real answer.

    I have a class which contains both QwtPlot, QwtPlotCurve and its array of data. I have certain function to update 'em.

    Calling the function manually yields the desired result: last value of graph is updated while data are shifted to 'front'.



    Qt Code:
    1. xGraph->updateCurve(xGraph->getValue()+2.4);
    2. xGraph->updateCurve(xGraph->getValue()+3.4);
    3. xGraph->updateCurve(xGraph->getValue()-9.8);
    4. xGraph->updateCurve(xGraph->getValue()+2.8);....
    To copy to clipboard, switch view to plain text mode 

    But using QThread (which I badly need to update the plot realtime), after I started the thread, the plot's just updated once. It's also no luck with me with QTimer timeout() signal--it yields similar result.

    Qt Code:
    1. class graphthread : public QThread{
    2. public:
    3. graphs *yeah;
    4.  
    5. graphthread(graphs *hereitis){
    6. yeah=hereitis;
    7. }
    8.  
    9. void run(){
    10. while (1){
    11. yeah->updateCurve(yeah->getValue()+0.4);
    12. // printf("%f\n",yeah->getValue()); // the plot won't update but this's repeatedly printed
    13. msleep(2000);
    14. }
    15. }
    16. };
    To copy to clipboard, switch view to plain text mode 


    note that there's little elevation in the rightmost

    'd anyone like to show me where I am doing wrong?
    Any help would be appreciated.
    Last edited by jendral_hxr; 24th May 2011 at 23:18.

Similar Threads

  1. Updating QwtPlot from QThread
    By atzengin in forum Newbie
    Replies: 3
    Last Post: 5th April 2012, 08:05
  2. Replies: 4
    Last Post: 29th April 2010, 06:11
  3. Replies: 1
    Last Post: 22nd January 2010, 14:34
  4. Replies: 4
    Last Post: 26th June 2008, 18:41
  5. Replies: 15
    Last Post: 8th May 2007, 11: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.