PDA

View Full Version : qgraphicsview: how to keep fixed size of an item while zooming?



corrado1972
18th February 2012, 11:21
I can't figure out to implement this scenario: I have a qgraficsscene populated with a ruler (qgrapchisitem) on the upper top of the scene, and other qgraphicsitems in the rest of the scene.
When the user use the mouse wheel to perform a zoom-in/out, all the scene is scaled by the view,the ruler too. But I don't want that the ruler is scaled!
I want to keep the rule at the same original size, without changing it's height and with. (intercepting the zooming signals, I will redraw the content of the ruler to appropriate scaling values).

How can I solve this? :confused:

Added after 1 3 minutes:

Another thought: it I want that the ruler doesn't change its size, while the other items does, I will face the problem that other items will overlap the rule.
One solution should be to put the ruler on another scene and the ruler view on the top of the items view:it has sense?

wysota
18th February 2012, 13:40
I see two solutions. One, less proper, is to use ItemIgnoresTransformations flag on rules items. Second solution, more proper, is to not make the ruler an item but instead draw it manually outside the view's viewport(). The scene is your world. The ruler is not part of it so making it part of the scene is counter-intuitive.

corrado1972
20th February 2012, 08:30
The scene is your world. The ruler is not part of it so making it part of the scene is counter-intuitive.
Thankyou wysota you helped me to understand that the ruler is not part of the items world!