I’m trying to get the x and y position from a QCursor variable
def run(self):
pos = QCursor.pos()
print(pos.toPoint())
this prints the following:
PyQt6.QtCore.QPoint(523, 590)
if i try to print pos.x or pos.y it prints the following:
<built-in method x of QPoint object at 0x7fe85027b0b0
When i googled i found out the mapFromGlobal() method, but i couldn’t make it work.
Is there any way to get X and Y values?
thanks
>Solution :
pos.x and pos.y are methods, not properties so they need to be called.
try:
pos.x()
pos.y()
Anytime you print an object in python and it looks like <built-in method ... that means the attribute is a method and needs to be invoked.