Results 1 to 3 of 3

Thread: QwtPlot crash in Mac OS X

  1. #1
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Red face QwtPlot crash in Mac OS X

    Hello Qt gurus,

    I have written a code that runs a step by step analysis and in after each step, updates a plot of the results. For the plot, I have sub-classed QwtPlot as follows:

    Qt Code:
    1. RPlotWidget::RPlotWidget(QWidget *parent)
    2. : QwtPlot(parent)
    3. {
    4. setCanvasBackground(QColor(Qt::white));
    5. QwtLegend *legend = new QwtLegend(this);
    6. insertLegend(legend, QwtPlot::TopLegend);
    7. setMargin(5);
    8. setCanvasLineWidth(0);
    9. plotLayout()->setCanvasMargin(0);
    10. plotLayout()->setSpacing(0);
    11.  
    12. QFont labelFont("Times New Roman", 10);
    13. setAxisFont(QwtPlot::xBottom, labelFont);
    14. setAxisFont(QwtPlot::yLeft, labelFont);
    15.  
    16. QFont titleFont("Times New Roman", 12, QFont::Bold);
    17. QwtScaleWidget *bottomAxis = axisWidget(QwtPlot::xBottom);
    18. QwtText bottomText = bottomAxis->title();
    19. bottomText.setFont(titleFont);
    20. bottomAxis->setTitle(bottomText);
    21. bottomAxis->setMargin(0);
    22.  
    23. QwtScaleWidget *leftAxis = axisWidget(QwtPlot::yLeft);
    24. QwtText leftText = leftAxis->title();
    25. leftText.setFont(titleFont);
    26. leftAxis->setTitle(leftText);
    27. leftAxis->setMargin(0);
    28.  
    29. QwtPlotMagnifier *plotMagnifier = new QwtPlotMagnifier(canvas());
    30. plotMagnifier->setEnabled(true);
    31. plotMagnifier->setMouseButton(Qt::MidButton);
    32.  
    33. QwtPlotPanner *plotPanner = new QwtPlotPanner(canvas());
    34. plotPanner->setEnabled(true);
    35. plotPanner->setMouseButton(Qt::LeftButton);
    36.  
    37. QwtPlotZoomer *plotZoomer = new QwtPlotZoomer(canvas(), true);
    38. plotZoomer->setMousePattern(0, Qt::LeftButton, Qt::ControlModifier);
    39. plotZoomer->setMousePattern(1, Qt::NoButton);
    40. plotZoomer->setMousePattern(2, Qt::NoButton);
    41. plotZoomer->setEnabled(true);
    42. }
    To copy to clipboard, switch view to plain text mode 

    I am using the above class in my analysis as follows:

    Qt Code:
    1. // Declare the plotting variables
    2. QPointer<QwtPlot> thePlot = 0;
    3. QwtPlotCurve *y1Curve = 0;
    4. QwtPlotCurve *y2Curve = 0;
    5. QVector<double> xVector;
    6. xVector.append(0.0);
    7. QVector<double> y1Vector;
    8. y1Vector.append(0.0);
    9. QVector<double> y2Vector;
    10. y2Vector.append(0.0);
    11.  
    12. int x = 0;
    13.  
    14. while (x <= maxIterations) //Stop condition of the analysis
    15. {
    16. x++;
    17.  
    18. // Instatiating thePlot
    19. if (!thePlot) {
    20. thePlot = new RPlotWidget(mainWindow);
    21. thePlot->show();
    22. thePlot->setAxisTitle(QwtPlot::xBottom, "x");
    23. thePlot->setAxisTitle(QwtPlot::yLeft, "y");
    24.  
    25. // Instantiating two curves
    26. y1Curve = new QwtPlotCurve(QString("y1"));
    27. y1Curve->setPen(QColor(Qt::red));
    28. y1Curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    29. y1Curve->attach(thePlot);
    30.  
    31. y2Curve = new QwtPlotCurve(QString("y2"));
    32. y2Curve->setPen(QColor(Qt::blue));
    33. y2Curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    34. y2Curve->attach(thePlot);
    35. }
    36.  
    37. double y1, y2;
    38.  
    39. // ... Run the analysis, evaluate y1 and y2
    40.  
    41. // Updating the plotting value vectors
    42. xVector.append(x);
    43. y1Vector.append(y1);
    44. y2Vector.append(y2);
    45.  
    46. // Updating the plot
    47. y1Curve->setData(xVector, y1Vector);
    48. y2Curve->setData(xVector, y2Vector);
    49. thePlot->replot();
    50. }
    To copy to clipboard, switch view to plain text mode 

    This code works perfectly in Windows, but it crashes while running the "setData(...)" for the second iteration in Mac OS X. I have gone through all the threads about Qwt and Mac, yet I have not found any solutions .

    I am using Qt 4.5.2 and Qwt 5.2.0. The Qwt is built statically.

    Thanks a lot for any help in advance.
    Mojtaba
    Last edited by sirmojtaba; 17th August 2009 at 22:40.

  2. #2
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QwtPlot crash in Mac OS X

    Please anyone??? Any ideas? I am really stuck!

  3. #3
    Join Date
    Aug 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QwtPlot crash in Mac OS X

    Please feel free to close the thread. I figured it out!

Similar Threads

  1. QwtPlot - promote to custom widget
    By MrGarbage in forum Qwt
    Replies: 7
    Last Post: 10th February 2011, 11:12
  2. Crash: Heap corruption due to selectedRows()
    By Ankitha Varsha in forum Qt Programming
    Replies: 16
    Last Post: 1st October 2010, 01:55
  3. QwtPlot inside QScrollArea
    By mastupristi in forum Qwt
    Replies: 3
    Last Post: 13th October 2009, 05:28
  4. QString comparison gives wierd crash
    By supergillis in forum Qt Programming
    Replies: 0
    Last Post: 1st June 2009, 23:09
  5. QMdiArea + QwtPlot = Crash?
    By exdream in forum Qwt
    Replies: 2
    Last Post: 1st January 2009, 14:39

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.