qt - QGraphicsSvgItem positioning after rotation -


Text after "div class =" itemprop = "text">

When I try to rotate a QGraphicsSvgItem object and set a position I have a strange issue / feature had to face .

Check the following example: For simplicity I have a .svg which is a blue rectangle. I create two QGraphicsSvgItem using the file And I rotate them with 90 degrees. I had set both of them in one place, yet rotated one 'wrong' (maybe the right behavior) is located. It seems that the X, Y coordinate (top-left corner) is now in the top-right corner, it is not as if it has not been rotated. It looks awkward from my point of view, I hope that when I rotate and position, then the shape should be the 'first point' where the size is 'starting'.

I hope that with the source code it is more understandable that I have written the above:

  SVGDOM * BubbleDam = Shodogram-> Bubble (); _bubble = New DrawableSvgItem (sh-> Message (), BubbleDam-> Bytere ()); This- & gt; AddItem (_bubble); _bubble- & gt; SetPos ((-> this-> width () -_bubble-> the sceneBoundingRect () width ()) / 2, (this-> height () - _bubble- & gt ;. sceneBoundingRect () height ( ) ) / 2); QDebug () & lt; & Lt; "Bubble Pauses:" & lt; & Lt; _bubble- & gt; Event (); QDebug () & lt; & Lt; "Bubble boundright:" & lt; & Lt; _bubble- & gt; BoundingRect (); QDebug () & lt; & Lt; "Bubble Rect:" & lt; & Lt; _bubble- & gt; Visible bounding (); QDebug () & lt; & Lt; "Bubble Toplecht:" & lt; & Lt; _bubble- & gt; ViewBoundingCrack () TopLeft (); DrawableSvgItem * bubble2 = New DrawableSvgItem (sh-> Message (), BubbleDam-> Bytere ()); This- & gt; AddItem (bubble2); Bubble2-> SetRotation (90); Bubble2-> SetPos (_bubble- & gt; position ()); QDebug () & lt; & Lt; "Bubble 2 status:" & lt; & Lt; Bubble2-> Event (); QDebug () & lt; & Lt; "Bubble 2 Bondedirect:" & lt; & Lt; Bubble2-> BoundingRect (); QDebug () & lt; & Lt; "Bubble 2 Rect:" & lt; & Lt; Bubble2-> Visible bounding (); QDebug () & lt; & Lt; "Bubble 2 toplate:" & lt; & Lt; Bubble2->. SceneBoundingRect () topLeft ();  

DrawableSvgItem is only an extension of QGraphicsSvgItem, I created the item to drag the source path. Currently I'm not using it

Output:. Bubble position: QPointF (413.5, 297) Bubble boundindRect: QRectF (0,0 171x117) Bubble Rect: QRectF (296.5297 117x171) Bubble topleft: QPointF (296.5, 297) Bubble2 Position : QPointF (413.5, 297) Bubble2 boundindRect: QRectF (0,0 171x117) Bubble2 Rect: QRectF (411.458297 173.016x119.967) Bubble2 topleft: QPointF (411.458, 297) < P> In pictures, I expect the following:

Enter image details here < / P>

But I found the following image:

Enter image details here

I am the same Found Msya.

Bubble 2 Your change has been rotated around the original point. It is 0,0 by default in bubble 2 coordinates, except for bubble2-> SetPos () , set this point to 0b to 0b so that you only need to adjust bubble2-> The desired status is setPos () . You can change the original point change by setTransformOriginPoint ()

Edit 2014/11/05:.

The bubble2-coordinates of upper-left bubble2 are defined in. These coordinates are not being replaced by item changes, after the rotation, the top-left corner of the item has the same angle as the first. This point is placed by setPos () so Figure 2 shows the correct behavior in the corner, you want to place it on the bubble (x, y), bottom-left corner of bubble 2. To get the picture 1, you only need to enter 1 code as your code In the final step, take Bubble 2 from its height to the right

  bubble2-> Setup (413.5 + 117, 297)  

Or set the conversion of the original point of the plant in the left corner of bubble 2 as the first step

  Bubble2-> setTransformOriginPoint (0,117)  

Comments