Important: Please read the Qt Code of Conduct -

Event Problems caused by qCursor::setPos

  • Hello Guys,

    I posted this problem also on another forum. After that, I thought it could be better to ask on an official qt forum.

    I am developing since few months a CAD application based on OpenGL view and camera perspective. Since finishing my camera implementation, there is a bug in my code, but did´t fixed it due its low priority.
    After finishing most of my core development, I decided to fix the bug.

    So here is my Problem:

    To move arround the camera with the mouse movement, I am doing "installEventFilter()" on the Main Window, and pass those events in my camera event handler.
    During the mousemovement event, I am calculating the offset of movement by substracting currentCursorPosition with lastCursorPosition and set the position of the cursor to {x=widgetWidth/2, y=widgetHeight/2}, that the cursor stay in the center of widget.

    While I am moving my cursor, there is no keypress/release (or other input event) events passed. I figured out, that using the qCursor::setPos method causes a "losing the event focus or whatever". Because of this "event losing in that moment I set a new cursor position" stuff, I cant move my camera with the keyboard by pressing the WASD Keys and moving with my mouse arround.

    Do you have similar experience and probably solutions? Do I have a concept fail? Is there a better implementation?

    Currently, I am at my working station. On request, I am going to post some parts of my source code.

    • Ercan

Log in to reply