Search code examples
qtqgraphicsview

QGraphicsView: preserve item size


I am realy newby in Qt Graphics-View
I have a very large 2D scene that should be rendered using QGraphicsView. A scene include several points of interest, each of which should be drawn with some marker (square, triangle, ellipse, etc.) The problem is that marker should be drawn in constant size despite scene transformations (zooming in or out). So to draw marker properly I need to combine it's position in scene coordinates and it's imensions in pixels inside paint method. What is the most efficient way to do this? Surely I can recalculate item position to view coordinate each time the scene is zoomed or the view is resized, but I don't think it is correct solution. So any ideas?


Solution

  • Assuming the flags are QGraphicsItems, set the flag:

    QGraphicsItem::ItemIgnoresTransformations