Moving the cursor
Solved
General and Desktop
-
So say I open a new window. I want the mouse cursor to move to a random position on the window that was spawned ( the location doesn't really matter ).
Is it possible?
I tried using QCursor's setPos function and I had the position of the widget that was spawned with
this->pos();
but it didn't work -
Hi,
How exactly did you implement that ?
On a side note, you should really think about that idea. People usually don't find it nice that their cursor starts moving around without them asking for some sort of assistance for that.
-
I'm implementing it like this:
def move_cursor(self, x, y): screen = QGuiApplication.primaryScreen() cursor = QCursor() cursor.setPos(x, y)
If I replace
cursor.setPos(x, y)
withcursor.setPos(screen, x, y)
then it errors and says:TypeError: arguments did not match any overloaded call: setPos(int, int): argument 1 has unexpected type 'QScreen' setPos(QPoint): argument 1 has unexpected type 'QScreen'```