Thanks again Uwe.

I have rewrote the code in the renderer as following :

void QwtPlotRenderer::renderTo (QwtPlot* plot, QPrinter& printer)
{
int w = printer.width ( ), h = printer.height ( );
int cw = plot->canvas ( )->width ( ), ch = plot->canvas ( )->height ( );
QRectF rect (0, 0, w, h);
double caspect = cw / ch;
if (caspect >= 1.) rect.setHeight (rect.width ( ) / caspect);
else rect.setWidth (rect.height ( ) * caspect);

QPainter p (&printer);
render (plot, &p, rect);
}

It works, but not perfectly, the aspect ratio on the sheet is about 0.95, and I have to multiply height with a coef in order to kept my ratio to 1.

Charles

Quote Originally Posted by Uwe View Post
Well you want to have a fixed ratio between the scale ranges and the rectangle on the target device. So you need to adjust one of them.

What you can do easily is to set the rectangle for the plot on the target device. When you know the rectangle for your canvas you could use a QwtPlotLayout to find out how many pixels title, scales and legend need and add them to your canvas rectangle.

The other option is to adjust the scales. For this you also have to calculate the layout for the canvas with a QwtPlotLayout first. But be aware of the problem, that changing the scales might change the size of the canvas ( f.e. tick labels need more space ).

Uwe