PDA

View Full Version : Issues when upgrading Qwt from 6.0.2 to 6.1.0



freshairfly
17th January 2014, 10:03
Hi All,

First of all, Qwt is an excellent plot library. ;)
I met two issues when I'm trying upgrade qwt from 6.0.2 to 6.1.0.
1. X axis zoom only (see pic please). I overwritten drawRubberBand of QwtPlotZoomer. But it doens't work with Qwt-6.1.0.
9943

void TrendPlotZoomer::drawRubberBand(QPainter* painter) const
{
const QPolygon pa = adjustedPoints(pickedPoints());
if (pa.count() < 2)
return;

const QPoint& p1 = pa.first();
const QPoint& p2 = pa.last();

QRect rect = QRect(p1, p2).normalized();
QRectF prect = pickArea().boundingRect();
rect.setY(prect.y());
rect.setHeight(prect.height());

if (painter->pen().color() != Qt::color1) {

QColor color = painter->pen().color();
color.setAlpha(50);
painter->setBrush(color);
}
else {
painter->setBrush(painter->pen().color());
}

QwtPainter::drawRect(painter, rect);
}



2. How to hide the frame line of canvas in 6.1.0?
With 6.0.2, I did like this:

canvas()->setLineWidth(0);
canvas()->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);

Althrough the canvas is an instance of QFrame, I want to how to turn off the frame line elegantly.

Uwe
17th January 2014, 15:09
1. X axis zoom only (see pic please). I overwritten drawRubberBand of QwtPlotZoomer. But it doens't work with Qwt-6.1.0..
What exactly means "doesn't work" ?


2. How to hide the frame line of canvas in 6.1.0?
In Qwt 6.1 you can have a QwtPlotCanvas or a QwtPlotGLCanvas, where QWidget is the common base class. That's why QwtPlot::canvas() returns a QWidget now.
You might use use a dynamic_cast - or like it is done in the examples:


QwtPlotCanvas *canvas = new QwtPlotCanvas();
canvas->setXYZ(...);

plot->setCanvas( canvas );Uwe

freshairfly
18th January 2014, 01:41
Uwe,

Thanks for your reply.
"Doesn't work" means doesn't draw the "rubber band" same as 6.0.2.:D
To zoom on X axis only, when user dragging the mouse, the "Rubber Band" should be full of canvas on Y direction with semitransparent background (just like the pic of previsous post).

The code I posted previous did work as I expected. But when I upgrade the Qwt to 6.1.0. The "Rubber Band" looks like this:
9944
I debug the code, and I found setClipPath&setClipRect in QwtWidgetOverlay should be the reason. So my question is how to draw the "Rubber Band" same as Qwt6.0.2 exactly.

freshairfly
19th January 2014, 10:01
Uwe,

The issue was resolved :) via overwritting the rubberBandMask() of the zoomer.

Thanks again.