Use custom image in QCursor

前端 未结 1 1401
广开言路
广开言路 2020-12-21 12:07

I have a .bmp image that I would like to use as a cursor for my GUI. The QCursor Documentation suggests that this is possible (\"To create a cursor with your own bitmap, eit

相关标签:
1条回答
  • 2020-12-21 12:25

    If it can help anyone googling to here, and provided you can give a value to whatEverColor to be the transparent color. In __init__ :

    pm = QtGui.QPixmap('image.bmp')
    bm = pm.createMaskFromColor(whatEverColor, Qt.MaskOutColor)
    pm.setAlphaChannel(bm)
    cursor = QtGui.QCursor(pm)
    self.setCursor(cursor)
    
    0 讨论(0)
提交回复
热议问题