Translate code interpretation of pyqt5?

def paintEvent(self, paintEvent):
    painter = QPainter(self)
    painter.translate(self.width()/2, self.height()/2)
    painter.rotate(45) 
    painter.translate(-self.width()/2, -self.height()/2) -sharp 

as shown in the figure and code, according to my understanding,

  1. translate width/2
  2. rotate 45
  3. Pan-width/2

the result should be green, but it is actually red

how should I explain it?

Dec.20,2021

No pyqt, seems to be a problem with the center of rotation.
Press upper left corner to rotate to get green .
Press the midpoint of the rectangle to rotate to get red .

Menu