Search code examples
qtpyqtpyqt5mouse-cursor

How to change cursor size in PyQt5?


I want to implement brush cursor like in most image editors when cursor is a circle that change its size according to brush size. I've read the docs and found only setShape method, but no setSize. Is it possible in Qt to change cursor size?


Solution

  • pixmap = QPixmap("image.png")  # Replace with the path to your custom cursor image, brush in your case
    pixmap = pixmap.scaled(30, 30)  # Set the desired size
    cursor = QCursor(pixmap)
    self.setCursor(cursor)
    

    you can change the size and the "form" of your cursor in PyQt5 by creating a pixmap and then assigning in to your cursor