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

Martin Hofius Martin at hofius-online.com
Wed Aug 19 13:34:59 CEST 2009


Am Mittwoch, 19. August 2009 schrieb vronskij:
> 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?
place the rectangle around the coordnate systems root... (and move the 
coordinate system whereever you want ;-)
Martin

>
> 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





More information about the Qt-interest-old mailing list