from PyQt4.QtGui import * class Example(QWidget): def paintEvent(self, event): painter = QPainter(self) painter.setPen(QPen(Qt.black, 4)) # Draw a rectangle painter.drawRect(50, 50, 100, 100) # Rotate the painter by 45 degrees painter.rotate(45) # Draw the rectangle again (now rotated) painter.drawRect(50, 50, 100, 100) app = QApplication([]) ex = Example() ex.show() app.exec_()In this example, a QWidget is created and the `paintEvent()` method is redefined. Within this method, a QPainter object is created and a black pen with a width of 4 is set. The `drawRect()` function is then called to draw a rectangle with a top-left corner at (50, 50) and a width and height of 100 pixels. The `rotate()` function is then called to rotate the painter by 45 degrees. Finally, the `drawRect()` function is called again with the same coordinates as before, which will now draw a rotated rectangle. Overall, the `QPainter.rotate()` function can be used in conjunction with other QPainter functions to create more complex and dynamic graphical user interfaces.