Hey guys,

I have been trying to get the QGraphicsView::setTransform( const QTransform & ) to work. I have (simplified):

Qt Code:
  1. class QPlot : public QGraphicsView
  2. {
  3. ...
  4. protected:
  5. resizeEvent( QResizeEvent *event );
  6. private:
  7. }
To copy to clipboard, switch view to plain text mode 

with implementation:
Qt Code:
  1. QPlot::QPlot( QWidget *parent )
  2. : QGraphicsView( parent ),
  3. scene( new QGraphicsScene() )
  4. {
  5. // prepare
  6. //setRenderHints( QPainter::Antialiasing );
  7. setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
  8. setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
  9. scene->setSceneRect( 0.0, 0.0, 100.0, 100.0 );
  10.  
  11. // initial transformation
  12. QTransform transform;
  13. QRectF worldRect( QPointF(0.,0.), QPointF(100.,100.) );
  14. QRectF sceneRect( QPointF(0.,0.), QPointF(100., 100.) );
  15. QTransform::quadToQuad(QPolygon(worldRect), QPolygon(sceneRect), transform);
  16.  
  17. setSceneRect( sceneRect );
  18. setTransform( transform );
  19.  
  20. // x-grid
  21. scene->addLine( 100.0, 0.0, 0.0, 0.0 );
  22. scene->addLine( 100.0, 20.0, 0.0, 20.0 );
  23. scene->addLine( 100.0, 40.0, 0.0, 40.0 );
  24. scene->addLine( 100.0, 60.0, 0.0, 60.0 );
  25. scene->addLine( 100.0, 80.0, 0.0, 80.0 );
  26. scene->addLine( 100.0, 100.0, 0.0, 100.0 );
  27. // y-grid
  28. scene->addLine( 0.0, 0.0, 0.0, 100.0 );
  29. scene->addLine( 20.0, 0.0, 20.0, 100.0 );
  30. scene->addLine( 40.0, 0.0, 40.0, 100.0 );
  31. scene->addLine( 60.0, 0.0, 60.0, 100.0 );
  32. scene->addLine( 80.0, 0.0, 80.0, 100.0 );
  33. scene->addLine( 100.0, 0.0, 100.0, 100.0 );
  34. // QPLotScale transform check
  35. setScene( scene );
  36. }
  37. void QPlot::resizeEvent( QResizeEvent *event )
  38. {
  39. fitInView( scene->sceneRect(), Qt::IgnoreAspectRatio );
  40.  
  41.  
  42. qDebug() << transform().m11() << transform().m12() << transform().m13() << endl
  43. << transform().m21() << transform().m22() << transform().m23() << endl
  44. << transform().m31() << transform().m32() << transform().m33() << endl;
  45. }
To copy to clipboard, switch view to plain text mode 
All I get is a FULL grid that stretches to fit the window size. This is okay, but...
I would like to have the grid (ten lines) to be transformed by the QTransform. I have searched the web for an example, but they always implement the transformation directly on the QPainter, not via the QGraphicsView
What I want is to have eg only a part of the grid to be shown (only the center squares, only the topleft corner, stuff like that). I have tried to ask on these forums before, but always without answer

Any help is appreciated!