View Full Version : QT Mouse Event outside Window/Widget

5th November 2014, 10:41
Im trying to make my mouse click in some screen coordinates when my program receives a trigger for do it.

Ive made it in C++ before, now Im trying to make it in Qt, heres a small example of what i mean.

C++ code

if (bin_trigger == 1)
SetCursorPos(screenXpos, screenYpos);
ZeroMemory(Input, sizeof(INPUT)* 2);
Input[0].type = INPUT_MOUSE;
Input[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
Input[1].type = INPUT_MOUSE;
Input[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(2, Input, sizeof(INPUT));

I would be happy to get some tips or some pseudo-code from someone who have made somthing similar.

Thank you in advance.

5th November 2014, 11:38
Qt is as C++ library so your application is still a C++ application.
Why don't you just use the code that you know to work?


5th November 2014, 12:23
There could be some kind of function already implemented in QT that I didnt knew. Thank you I will try to implement it with what i have.