문제

I'm trying to setup a custom QCursor in PySide, but there are no usable code samples on it. As I understand, there's pixmap, and the pixmap's mask, which is set with QPixmap.setMask().

I'm doing both:

    open_hand_px = QtGui.QPixmap('open_hand.png')
    open_hand_px.setMask(open_hand_px.mask())
    open_hand_cursor = QtGui.QCursor(pixmap=open_hand_px)
    self.setCursor(open_hand_cursor)

The image I'm using is loading fine, there are no errors, but the cursor refuses to change. I don't know what I'm doing wrong.

Thanks for your replies!

도움이 되었습니까?

해결책

From the docs:

About keyword arguments

Only optional arguments can be used as keyword arguments.

So, remove pixmap=:

open_hand_px = QtGui.QPixmap('open_hand.png')
open_hand_px.setMask(open_hand_px.mask())
open_hand_cursor = QtGui.QCursor(open_hand_px)
self.setCursor(open_hand_cursor)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top