2012-12-18 61 views
2

我試圖在PySide中設置一個自定義QCursor,但是沒有可用的代碼示例。據我所知,有pixmap和pixmap的掩碼,這是設置QPixmap.setMask()PySide:創建一個自定義QCursor

我做兩個:

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) 

我使用的是加載精細的圖像,沒有錯誤,但光標拒絕改變。我不知道我做錯了什麼。

感謝您的回覆!

回答

3

docs

關於關鍵字參數

只有可選參數可以作爲關鍵字參數。

因此,刪除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)