Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
6.7.1
-
None
-
Windows 10
VSCode
Description
So far with testing .setMouseTracking(True) not able to get it working when used in conjuction with mouseMoveEvent().
It only works when the mouse button is held down over the widget.
Maybe I'm missing something
Please help.
Python 3.10
Here is my basic example
from PySide6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
from PySide6.QtGui import QMouseEvent
import sys
class MyWidget(QWidget):
def {}init{}(self):
super().{}init{}()
self.setMouseTracking(True)
self.label = QLabel("Move the mouse inside the window")
layout = QVBoxLayout()
layout.addWidget(self.label)
self.setLayout(layout)
def mouseMoveEvent(self, event: QMouseEvent):
position = event.position() # Use position() instead of pos()
self.label.setText(f"Mouse moved to: {position.x(){color:#569cd6}}, {position.y(){color:#569cd6}}")
event.accept()
if {}name{} == "{}main{}":
app = QApplication(sys.argv)
widget = MyWidget()
widget.resize(400, 300)
widget.show()
sys.exit(app.exec())