PDA

View Full Version : To rotate widget



ajit
26th September 2007, 07:53
Hi am Ajit
I have created a widget of size ellipse
i want to rotate that ellipse-widget according to the left button mouse move till the left button is down

To create ellipse size widget, in the constructor i have written the following code

{
m_maskedRegion = QRegion(CENTER_X-26, CENTER_Y - 187, 203, 435, QRegion::Ellipse);
setMask(m_maskedRegion);
}

please help me
is there any function like for the QPainter there is rotate function

wysota
26th September 2007, 10:02
You have to reimplement the widget's paintevent and rotate the painter and render a pixmap of the widget to the rotated painter. But this way you'll only get a rotated "look" but not "feel". What is the widget anyway?

jpn
26th September 2007, 10:03
Store rotation as member variable
reimplement corresponding mouse event handlers to increase/decrease rotation
use QPainter::rotate() in paintEvent()

Of course, you will also have to apply the rotation to the mask as well. You can do that with QMatrix::map(QRegion).