I am experimenting with a WYSIWYG editor that allows a user to draw shapes on a page and the Qt graphics scene support seems perfect for this. However, instead of working in pixels I want all my QGraphicsItem objects to work in tenths of a millimetre but I don't know how to achieve this.

For example:

Qt Code:
  1. // Create a scene that is the size if an A4 page (2100 = 21cm, 2970 = 29.7cm)
  2. QGraphicsScene* scene = new QGraphicsScene(0, 0, 2100, 2970);
  3. // Add a rectangle located 1cm across, 1cm down, 5cm wide and 2cm high
  4. QGraphicsItem* item = scene->addRect(100, 100, 500, 200);
  5. ...
  6. QGraphicsView* view = new QGraphicsView(scene);
  7. setCentralWidget(view);
To copy to clipboard, switch view to plain text mode 

Now, when I display the scene above I want the shapes to appear at correct size for the screen DPI. Is this simply a case of using QGraphicsView::scale or do I have to do something more complicated?

Note that if I was using a custom QWidget instead then I would use QPainter::setWindow and QPainter::setViewport to create a custom mapping mode but I can't see how to do this using the graphics scene support.

Any advice on WYSIWYG support with scenes is welcome.