PDA

View Full Version : Rotating a pixmap inside a widget



Eneswar
2nd May 2011, 14:39
Hello, I need help with rotating a pixmap inside a widget. What I have is a Circle and a Pointer, they are both 2 seperated images. (Think about a Tachometer) I have already the pointer in the middle of the circle as I want. What I am failing with is to rotate the pointer as I want.

I can rotate it but its not rotating from the point where I need it to rotate. Right now it is rotating from somewhere I dont know where, I need the pointer to stay where it is and rotate from there.

ChrisW67
3rd May 2011, 02:04
Open Qt Assistant and look for "Analog Clock Example" in the Index

Eneswar
3rd May 2011, 09:56
Alright will do, thank you.





Im still having trouble figuring this out.

My code:

boolPainter.drawPixmap(0, 0, QPixmap(":/Image/CircleDark"));
boolPainter.drawPixmap(0,0, QPixmap(":/Image/Pointer"));

Its the Pointer I need rotate, could I get some kind of example or something?

Eneswar
3rd May 2011, 10:39
I have got it sorted with:


item->setTransform(QTransform().translate(x, y).rotate(45).translate(-x, -y));