[Qt-interest] How to rotate a rectangle with QPainter?

Chandru... sekarwagmare at gmail.com
Wed Aug 19 13:38:36 CEST 2009


the movement of QTransform is restricted only from top left to right  .

u can rotate by axis like
transform.rotate(xrot , Qt::YAxis);
transform.rotate(yrot, Qt::XAxis)

On Wed, Aug 19, 2009 at 4:44 PM, vronskij <vronskij at gmail.com> wrote:

> Hi,
>
> I want to rotate a rectangle. It middle of the rectangle should stay
> in the middle of the window.
>
> The rotate() method rotates the whole coordinate system. In other
> words, using this
> method, the rectangle rotates along its upper left point. I want to
> rotate the rectangle
> along its middle point.
>
> How to achieve this?
>
> Thanks,
>
> jan bodnar
>
> The code looks like:
>
>       rotate++
>
>       int w = width()
>       int h = height()
>
>       painter.translate(w/2, h/2)
>       painter.rotate(rotate)
>       painter.drawRect(QRect(0, 0, 200, 80))
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



-- 
WAGMARE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090819/9c07097b/attachment.html 


More information about the Qt-interest-old mailing list