Issue
I want to know how can i convert a QPointf position into a QPoint position in PyQt, because i need to set the mouse position using the position of an item. I've been trying with this, but nothing happens:
xq=node.pos().x()
yq= node.pos().y()
x=int(xq)
y=int(yq)
QtGui.QCursor.setPos(x,y)
Thanks in advance!
Solution
Try these commands in the interpreter:
from PyQt4 import QtGui, QtCore
point = QtCore.QPointF(100.2, 144.23)
QtGui.QCursor.pos(), QtGui.QCursor.setPos(point.toPoint()), QtGui.QCursor.pos()
# (PyQt4.QtCore.QPoint(1335, 691), None, PyQt4.QtCore.QPoint(100, 144))
But the real problem is probably that you use item coordinates, which you have to map to global coordinates.
See this answer. Basically he maps coordinates in the following way:
item -> scene -> view -> global
Answered By - gatto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.