Skip to content Skip to sidebar Skip to footer

Pyqt5: How To Set A Custom Mouse Pointer For Each Role?

1. Intro I'm creating an application in Python 3.7 with PyQt5 for the GUI. I would like to customize the mouse cursors in the application. Let's start from the standard cursor set

Solution 1:

# I'm coming```.

# 1. Set the cursor map
self.cursor_pix = QPixmap('exa.png')

# 2. Scale textures
self.cursor_scaled_pix = self.cursor_pix.scaled(QSize(20, 20), Qt.KeepAspectRatio)

# 3. Set cursor style and cursor focus position
self.current_cursor = QCursor(self.cursor_scaled_pix, -1, -1)

# 4. Set the cursor for the specified window
widget.setCursor(self.current_cursor)

Post a Comment for "Pyqt5: How To Set A Custom Mouse Pointer For Each Role?"