View Full Version : Having problems with transformations

10th October 2007, 15: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:



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


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