Python GUI编程网 > QWidget控件基类学习 > 设置鼠标形状和状态
python教程

设置鼠标形状和状态

发布日期:2020年11月23日 07:27
阅读:3362
作者:Python GUI编程网

设置鼠标形状和状态

00:00 / 01:23
1x
2x
1.5x
1.25x
1x
0.8x
0.5x

设置鼠标形状和状态

################################
# 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_())