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:
Code:
RPlotWidget
::RPlotWidget(QWidget *parent
){
setCanvasBackground
(QColor(Qt
::white));
insertLegend
(legend,
QwtPlot::TopLegend);
setMargin(5);
setCanvasLineWidth(0);
plotLayout()->setCanvasMargin(0);
plotLayout()->setSpacing(0);
QFont labelFont
("Times New Roman",
10);
setAxisFont
(QwtPlot::xBottom, labelFont
);
setAxisFont
(QwtPlot::yLeft, labelFont
);
QFont titleFont
("Times New Roman",
12,
QFont::Bold);
QwtText bottomText
= bottomAxis
->title
();
bottomText.setFont(titleFont);
bottomAxis->setTitle(bottomText);
bottomAxis->setMargin(0);
QwtText leftText
= leftAxis
->title
();
leftText.setFont(titleFont);
leftAxis->setTitle(leftText);
leftAxis->setMargin(0);
plotMagnifier->setEnabled(true);
plotMagnifier->setMouseButton(Qt::MidButton);
plotPanner->setEnabled(true);
plotPanner->setMouseButton(Qt::LeftButton);
plotZoomer->setMousePattern(0, Qt::LeftButton, Qt::ControlModifier);
plotZoomer->setMousePattern(1, Qt::NoButton);
plotZoomer->setMousePattern(2, Qt::NoButton);
plotZoomer->setEnabled(true);
}
I am using the above class in my analysis as follows:
Code:
// Declare the plotting variables
QPointer<QwtPlot> thePlot = 0;
QVector<double> xVector;
xVector.append(0.0);
QVector<double> y1Vector;
y1Vector.append(0.0);
QVector<double> y2Vector;
y2Vector.append(0.0);
int x = 0;
while (x <= maxIterations) //Stop condition of the analysis
{
x++;
// Instatiating thePlot
if (!thePlot) {
thePlot = new RPlotWidget(mainWindow);
thePlot->show();
thePlot
->setAxisTitle
(QwtPlot::xBottom,
"x");
thePlot
->setAxisTitle
(QwtPlot::yLeft,
"y");
// Instantiating two curves
y1Curve
->setPen
(QColor(Qt
::red));
y1Curve
->setRenderHint
(QwtPlotItem::RenderAntialiased,
true);
y1Curve->attach(thePlot);
y2Curve
->setPen
(QColor(Qt
::blue));
y2Curve
->setRenderHint
(QwtPlotItem::RenderAntialiased,
true);
y2Curve->attach(thePlot);
}
double y1, y2;
// ... Run the analysis, evaluate y1 and y2
// Updating the plotting value vectors
xVector.append(x);
y1Vector.append(y1);
y2Vector.append(y2);
// Updating the plot
y1Curve->setData(xVector, y1Vector);
y2Curve->setData(xVector, y2Vector);
thePlot->replot();
}
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
Re: QwtPlot crash in Mac OS X
Please anyone??? Any ideas? I am really stuck!
Re: QwtPlot crash in Mac OS X
Please feel free to close the thread. I figured it out!