Skip to content
Advertisement

How to rotate an QImage

I want to rotate my QImage by the amount of x.

I don’t want to use QPixMap or the PaintEvent if possible.

I have already searched for possible solutions but they didn’t work.

Right now i am trying to solve it with the QTransform method:

JavaScript

I don’t get any error message the image is just not rotated.

Advertisement

Answer

I found the mistake! Thank you furas: self.img = self.img.transformed(my_transform) was the first half of the solution! In PySide2 and PyQt5 you have to create the QPushButton again to get the new image displayed otherwise it is just changed but never displayed.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement