PDA

View Full Version : How to move the mouse ?



shad0w
2nd November 2008, 07:20
Hi there,

I want to manipulate the current mouse pointer position and wonder, how this would be done. The QTestLib framework module provides this functionality with QTest::mouseMove but this is no unit test. And without unit tests I don't want to use the QTest module (e.g. this needs the CONFIG variable to be extended by "qtestlib" in the *.pro file).

Maybe someone knows a better solution using the QtCore module? Searching the API I did not find any similar to QTest::mouseMove.

Greets.

pastor
2nd November 2008, 09:55
Hello!

Did you try this method?


void QCursor::setPos ( int x, int y ) [static]

shad0w
2nd November 2008, 12:30
No, I did not. But yes, this will work. The only pitfall is that the set cursor position will be interpreted as a global point. But it should be possible to map from widget coordinates to global ones.

Thanks.

pastor
2nd November 2008, 13:55
You're welcome!


But it should be possible to map from widget coordinates to global ones.

Yes, it will be possible with QWidget::map* methods