Results 1 to 2 of 2

Thread: Dynamic graph, access read violation

  1. #1
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Dynamic graph, access read violation

    Hello,

    I'm trying to make a plot which updates dynamically like in cpuplot example of QWT.
    Everything goes fine excepted that when I'm trying to set new datas with setRawSamples in Qt's timer I experiment read violation access. Here is my sample class :

    Qt Code:
    1. #include "StdAfx.h"
    2.  
    3. QTimeStepView::QTimeStepView(QWidget *parent)
    4. : QwtPlot(parent)
    5. , count(0.0)
    6. {
    7. {
    8. m_x.push_back(count);
    9. m_y.push_back(count);
    10.  
    11. count +=1;
    12.  
    13. m_x.push_back(count);
    14. m_y.push_back(count);
    15.  
    16. count +=1;
    17.  
    18. m_x.push_back(count);
    19. m_y.push_back(count);
    20.  
    21. count +=1;
    22. }
    23. this->setAutoReplot(false);
    24.  
    25. // Show a title
    26. setTitle( "This is an Example" );
    27.  
    28. // Show the axes
    29. setAxisTitle( xBottom, "Time" );
    30. setAxisTitle( yLeft, "Timestep" );
    31.  
    32. QwtPlotCurve *m_timestep = new QwtPlotCurve("timestep");
    33. m_timestep->attach(this);
    34. replot();
    35.  
    36. m_timestep->setRawSamples(&m_x[0], &m_y[0], m_x.size());
    37. replot();
    38.  
    39. {
    40. m_x.push_back(count);
    41. m_y.push_back(count);
    42.  
    43. count +=1;
    44. }
    45. m_timestep->setRawSamples(&m_x[0], &m_y[0], m_x.size());
    46. replot();
    47.  
    48. (void)startTimer(1000);
    49. }
    50.  
    51. QTimeStepView::~QTimeStepView()
    52. {
    53.  
    54. }
    55.  
    56. void QTimeStepView::timerEvent(QTimerEvent* event)
    57. {
    58. m_x.push_back(count);
    59. m_y.push_back(count);
    60.  
    61. count +=1;
    62.  
    63. m_timestep->setRawSamples(&m_x[0], &m_y[0], m_x.size()); //Here happens the error
    64. replot();
    65. }
    To copy to clipboard, switch view to plain text mode 

    Severals setRawSamples goes fine in constructor but if I try to make it in the timer it doesn't work.

  2. #2
    Join Date
    Jul 2011
    Posts
    2
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: Dynamic graph, access read violation

    Mea culpa.

    I redefined m_timestep whereas it was already defined in the .h

Similar Threads

  1. Access violation -- qobject.cpp
    By willief in forum Newbie
    Replies: 9
    Last Post: 14th February 2011, 22:55
  2. Access Violation - Crashing Application
    By LIRiot in forum Qt Programming
    Replies: 9
    Last Post: 5th December 2010, 23:10
  3. Access Violation with VS2008
    By Takatschio in forum Qt Programming
    Replies: 3
    Last Post: 19th August 2010, 09:16
  4. QModelIndexList access reading violation
    By Daxos in forum Qt Programming
    Replies: 3
    Last Post: 30th June 2010, 08:32
  5. Access Violation on Signal Emit
    By khagzan in forum Qt Programming
    Replies: 2
    Last Post: 25th September 2007, 22:51

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.