PDA

View Full Version : QwtPlotGrid



annili
31st August 2015, 16:36
I need to draw grid om QPixmap. I did that:
QwtPlotGrid grid;
grid.enableX(true);
grid.enableY(true);
grid.setMajorPen(QPen(Qt::black, 0, Qt::DashLine));
grid.setMinorPen(QPen(Qt::blue, 0 , Qt::DotLine));
and then draw :
grid.draw(&p, *_xMap, *_yMap, r1);

But nothing was happened. Thought the grid, that was attached to some QwtPlot did work and drew a grid.
Is there a way to draw QwtPlotGrid without attaching it to QwtPlot?
Thanks.

Uwe
31st August 2015, 18:46
How is your pixmap related to the plot coordinate system ?

Uwe

annili
3rd September 2015, 06:49
Well, probably in no way.

Well, probably in no way. Is there something I can do with it? I mean, I set a pixmap size. isn't that enough?

Uwe
3rd September 2015, 06:53
Well, probably in no way.
Then why using QwtPlotGrid, when all you want to do is to draw some horizontal/vertical lines. I would use QPainter::drawLine() directly().

Uwe

annili
3rd September 2015, 07:13
I'm using QwtPlotGrid because I need to draw exactly the same lines as on my QwtPlot widget. I would use it's grid but i need to draw a larger scale then there is on plot widget. But for some reason grid.draw(...) draw only fixed area that QwtPlot widget show on screen.
There is the screenshot of my QwtPlot :
11345
And there is image from QPixmap where i draw grid and curves:11346

Uwe
3rd September 2015, 13:24
Code is better than words here: have a look at the implementation of QwtPlotGrid::drawLines. Guess you will see immediately how the scale maps and the canvas rectangle need to be modified.

Uwe