PDA

View Full Version : Having problems with transformations



maverick_pol
10th October 2007, 16:52
Hi guys,

I have implemented my own QGraphicsScene::drawBackground(QPainter* ....) method.
I draw a map in that method, but before drawing, to get the correct image, I had to make these transformations:
(*****)


....
painter->translate(550,300);
painter->rotate(180);
painter->scale(-3.37778,3.37778);

painter->drawRect(m_rectangle);
...

and then I got the correct map drawn. In this method I also draw same rectangles.

Now, after I have my map and the rectangles drawn in the drawBackground(QPainter*..) I need to add some QGraphicsTextItems in the center of that rectangles, but I have problems with finding the transformation for the items to draw them in the correct place.
Now I need to add a QGraphicsTextItem in the center of the "m_rectangle";

I tried using the same transform (*****) for my items (like item->translate()...etc), but they I drawn in the wrong place.

How can I get the QGraphicTexItem added in the center of the m_rectangle(which is drawn in the drawBackground(QPainter*) ) ??

I do appreciate any ideas.
Thank you

Maverick

wysota
21st October 2007, 00:23
You can map rectangle between different matrices using QMatrix::map(). It's just a matter of picking the right pair of matrices.