赞
踩
import sys from PyQt5.Qt import * class Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle("鼠标移动") self.resize(500,500) self.move(200,200) #设置鼠标图标 pixmap=QPixmap("C:\\Users\\Administrator\\Desktop\\pyQT学习\\鼠标.png").scaled(15,15) curosor=QCursor(pixmap) self.setCursor(curosor) lable=QLabel(self) self.lable=lable lable.setText("aaaaaaa") lable.resize(100,100) lable.move(50,50) def mouseMoveEvent(self, QMouseEvent): print("鼠标移动",QMouseEvent.localPos()) #lable=self.findChild(QLabel) self.lable.move(QMouseEvent.localPos().x(),QMouseEvent.localPos().y()) app=QApplication(sys.argv) window=Window() window.show() sys.exit(app.exec_())
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。