如何僅在 Qlabel 中獲取滑鼠位置?我希望滑鼠位置從 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))
uj5u.com熱心網友回復:
我不知道self在你的情況下代表什么,但如果它是包含標簽的小部件或視窗,正如我所假設的,那么你可以使用這個坐標變換:
labelPos = self.ui.labelLOOPVIDEO.mapFrom(self, event.pos())
x = labelPos.x()
y = labelPos.y()
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/434938.html
下一篇:C 中的QtQdate函式與年份
