I actually use the same painter but not the same QwtPlotRenderer which I destroy when I don't have anymore plots to render. Should I keep it alive until I render the scale ?
I actually use the same painter but not the same QwtPlotRenderer which I destroy when I don't have anymore plots to render. Should I keep it alive until I render the scale ?
This is the painter transformation you have to use for rendering your scale:
UweQt Code:
QTransform transform; transform.scale( double( painter->device()->logicalDpiX() ) / yourScale->logicalDpiX(), double( painter->device()->logicalDpiY() ) / yourScale->logicalDpiY() );To copy to clipboard, switch view to plain text mode
Hi,
Could you be more specific about where to transform and how should I render ?
I have the scale widget. I create the QTransform. I apply it to the painter.
And then ? QwtPlotRenderer extracted code ? QWidget::render ? I tried those two but it did not render properly (or rendered nothing).
Since I added a title to the axis, the size of the text is also to fix.
The axis has to be painted using scaleWidget->scaleDraw()->draw() scaleWidget->drawTitle() and scaleWidget->drawColorBar - like it is done inside of QwtPlotRenderer::renderScale().
But as all geometries are internally stored in screen metrics you have to set up the painter transformation ( see above ), that translates and scales them to paint device coordinates.
If your layout ( including the geometry where you want to render the extra scale ) is in paint device coordinates you have to use the inverted transformation to map the geometry of the scale into screen coordinates. Then you have to assign the transformation to the painter and call a method, that does something similar for your extra scale - like what is done in QwtPlotRenderer::renderScale(). Of course this method could have been won from stripping down the implementation of QwtPlotRenderer::renderScale().
Uwe
Bookmarks