PySide:创建自定义QCurs

2024-06-28 20:45:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在PySide中设置一个自定义的QCursor,但上面没有可用的代码示例。据我所知,有pixmap和pixmap的掩码,它是用QPixmap.setMask()设置的。在

我两个都在做:

    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)

我使用的图像加载良好,没有错误,但光标拒绝更改。我不知道我做错了什么。在

谢谢你的回复!在


Tags: 代码示例pngmaskopencursorpysidehand
1条回答
网友
1楼 · 发布于 2024-06-28 20:45:13

docs

About keyword arguments

Only optional arguments can be used as keyword arguments.

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

相关问题 更多 >