Hi all,
I have a QGraphicsView inherited class who has a background, mouse overrided to allow pan on right click.
The Drag mode is set to RubberDrag to allow selection using rectangle on left click.
Mouse wheel is overrided to allow zoom who is just a change of Transform.
The problem is on the foreground, when I paint a text the size change because of zoom.
Another problem is this foreground is painted multiple time, normally it should just be painted on the bottom right of the window.
For example, the problem is visible when a selection rectangle is added using left click.
Here the code of the foreground :
Qt Code:
  1. void CEditorNodeView::drawForeground( QPainter* painter, const QRectF& rect )
  2. {
  3. QFont Font( "Arial", 20 );
  4. QFontMetrics FontMetrics( Font );
  5. painter->setPen( QColor( 128, 128, 128, 128 ) );
  6. painter->setFont( Font );
  7. const int X = rect.right();
  8. const int Y = rect.bottom();
  9. const int Width = FontMetrics.width( m_Name );
  10. const int Height = FontMetrics.height();
  11. painter->drawText( X - Width - 5, Y - Height, Width, Height, Qt::AlignCenter, m_Name );
  12. }
To copy to clipboard, switch view to plain text mode 
If I add update() at the end of the function the problem is not visible but that mean that need update all the viewport always.
To use this hack NoViewportUpdate need to be set too to not update multiple time.
One solution for this problem ?
Thanks for the help