Try this:
{
p.save();
// set up "traditional" coordinate system
p.setWindow( -10, -10, 20, 20 );
p.scale( 1.0, -1.0 );
QTransform t = p.combinedTransform();
// draw the graph
p.drawLine( 0, 0, 5, 5 );
// revert to the default coordinate system
p.restore();
// draw labels in the Right Place(tm) using t transform
p.drawText( t.map( pt ), "xxx" );
}
void paintEvent( QPaintEvent * )
{
QPainter p( this );
p.save();
// set up "traditional" coordinate system
p.setWindow( -10, -10, 20, 20 );
p.scale( 1.0, -1.0 );
QTransform t = p.combinedTransform();
// draw the graph
p.drawLine( 0, 0, 5, 5 );
// revert to the default coordinate system
p.restore();
// draw labels in the Right Place(tm) using t transform
QPoint pt( 7, 7 );
p.drawText( t.map( pt ), "xxx" );
}
To copy to clipboard, switch view to plain text mode
Instead of using save()/restore() you can prepare the right QTransform yourself and map all points.
Another solution is to scale the font, but it might not work with all fonts. Also take a look at Qwt.
Bookmarks