What is the meaning of “the item's view geometry and scene geometry will be maintained separately”?

好久不见. 提交于 2019-12-13 04:43:02

问题


The documentation for the QGraphicsItem::ItemIgnoresTransformations flag says

The item ignores inherited transformations (i.e., its position is still anchored to its parent, but the parent or view rotation, zoom or shear transformations are ignored). This flag is useful for keeping text label items horizontal and unscaled, so they will still be readable if the view is transformed. When set, the item's view geometry and scene geometry will be maintained separately. You must call deviceTransform() to map coordinates and detect collisions in the view. By default, this flag is disabled. This flag was introduced in Qt 4.3. Note: With this flag set you can still scale the item itself, and that scale transformation will influence the item's children.

Of course I have read the QGraphicsItem details, the QGraphicsScene details, the QGraphicsView details, and the Graphics View Framework.

There are also several questions about the ItemIgnoresTransformations flag like Fixed size QGraphicsItems in multiple views?

But I still do not understand the sentence in bold face. What does it mean ?

The problem that rose this concern is described in PyQt: Moving multiple items with different ItemIgnoresTransformations flags, but maybe this question was too long, or too pyqt oriented at first sight. And it was more about moving items. So here I'm trying to better focus.


回答1:


Imagine situation that parent is rotated 45 degrees or even have some sheer. Since current item ignores this transformation it stays strait (not rotated).
Now ask question how this impacts on item size and position? Parent may maintain geometry of item (for example by using layout) but it doesn't take into account this flag, so some geometry (which is in parent units) will be set but effectively items scene rect may appear different since item ignores transformation and it is not rotated squeezed zoomed as a parent.

So from parent point of view geometry has some value but form scene point of view it is different.

It would be best if you try to see how it works in practice It is hard to describe problem clearly.



来源:https://stackoverflow.com/questions/27899643/what-is-the-meaning-of-the-items-view-geometry-and-scene-geometry-will-be-main

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!