Mikhail  Zimka
Mikhail Zimka

Reputation: 714

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?

Upvotes: 0

Views: 306

Answers (2)

Kantharaju Dudda
Kantharaju Dudda

Reputation: 16

As TheDarkKnight said above, you can set the flag QGraphicsItem::ItemIgnoresTransformations for the any Item which is derived from QGraphicsItem class to avoid transformation while zooming. you can read Qt document for the additional flags which will be helpful in understanding rendering of each QGraphicsItem.

Upvotes: 0

TheDarkKnight
TheDarkKnight

Reputation: 27611

Assuming the flags are QGraphicsItems, set the flag:

QGraphicsItem::ItemIgnoresTransformations

Upvotes: 2

Related Questions