[英]How to get mouse position only in Qlabel? (for pyqt5)
如何只在Qlabel中獲取鼠標position? 我希望鼠標 position 在 qlabel 中啟動。 所以: qlabel循環
我的代碼
def mousePressEvent(self, event):
ret = self.hasMouseTracking() # Back to mouse MouseTracking The state of
self.ui.labelLOOPVIDEO.setText(' The mouse moved :%s' % ret)
x = event.x()
y = event.y()
self.ui.labelLOOPVIDEO.setText(' mouse x coordinate :%s , mouse y coordinate :%s' % (x, y))
我不知道在你的情況下self
代表什么,但如果它是小部件或 window 包含 label,正如我假設的那樣,那么你可以使用這個坐標轉換:
labelPos = self.ui.labelLOOPVIDEO.mapFrom(self, event.pos())
x = labelPos.x()
y = labelPos.y()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.