Unsolved Rotate QBrush Texture Pattern
-
Hello,
I am drawing square, and each square has its given angle.
I use QPixmap as the Brush texture Pattern.
How to rotate the QPixmap of the QBrush in function of the square angle?
Thank you -
You can match the rotation of the rectangle and the brush with its setTransform() method, but it might be easier to just set the painter transform and let it transform the rectangle and the brush in one go. Something like:
QPainter p(whatever); QBrush b(QPixmap("something.png")); p.save(); p.translate(rect_x, rect_y); p.rotate(angle); QRect r(0, 0, rect_width, rect_height); p.fillRect(r, b); p.restore();
The
save()/restore()
calls are there to preserve the original transform and are only needed if you want to use that painter for something else too.