PyQt5 设置鼠标形状

################################
PyQt5中文网 - PyQt5全套视频教程 #
   https://www.PyQt5.cn/     #
        主讲: 村长            #
################################

from PyQt5.Qt import *
import sys

class Window(QWidget):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("鼠标操作")
        self.resize(600, 500)
        self.func_list()

    def func_list(self):
        self.func()

    def func(self):
        label = QLabel(self)
        label.resize(150, 150)
        label.move(50, 50)
        label.setText('标签学习')
        label.setStyleSheet('background-color:green')
        label.setCursor(Qt.DragLinkCursor)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = Window()

    pixmap = QPixmap('aaa.png')
    new_pixmap = pixmap.scaled(150, 150)
    cursor = QCursor(new_pixmap, 120, 120)
    window.setCursor(cursor)

    window.show()
    sys.exit(app.exec_())

Original: https://www.cnblogs.com/lvdongjie/p/16331112.html
Author: Avatarx
Title: PyQt5 设置鼠标形状

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/546525/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球