Embedded_linux [SOLVED]: Qt4.8 embedded. Adjusting mouse input with QCursor::setPos() results in a twitching cursor

Embedded_linux [SOLVED]: Qt4.8 embedded. Adjusting mouse input with QCursor::setPos() results in a twitching cursor

Home Forums Embedded Linux Embedded_linux [SOLVED]: Qt4.8 embedded. Adjusting mouse input with QCursor::setPos() results in a twitching cursor

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4351

    Anonymous

    QuestionQuestion

    I’m trying to adjust user mouse input (slow down/fasten mouse pointer) by calculating and setting the new position of the pointer every mouseMoveEvent().

    It looks like the pointer is drawn in it’s normal position before mouseMoveEvent() is executed. This results in a bad looking, twitching cursor.

    Here is an example of how I would try to keep the pointer in a place, ignoring user input.
    Expected behaviour: The pointer stays steady in one place when I move the mouse.
    Observed bahaviour: The pointer jiggles. For a fraction of a second, a new pointer is drawn in the position where the mouse is moved, after which it’s moved back to it’s oldPosition.

    void MainWindow::mouseMoveEvent(QMouseEvent *)
    {
        // [event->accept();] Setting this does not help
        // [setCursor(Qt::BlankCursor);] Setting this does not help
    
        QCursor::setPos(oldPosition);
    
        // [setCursor(Qt::ArrowCursor);]
    }
    

    P.S. May be there are other ways to adjust mouse sensitivity in qt embedded. Am I doing it right?

    #4352

    Anonymous

    Accepted AnswerAnswer

    Short answer: No.

    Unfortunately, there is no way to adjust mouse sensitivity using only QT libraries.

    The twitching you are experiencing is because the OS does the work of drawing the mouse pointer, the frequency of which can be different from how frequently you receive mouse move events from the OS.

    There is also no way to tell QT or the OS to send you mouse move events before every frame the cursor is drawn.

    Workaround: You could hide the mouse pointer completely, and draw your own. This way you will have full control over when the cursor is drawn avoiding the glitches.

    Source: http://stackoverflow.com/questions/42411319/qt4-8-embedded-adjusting-mouse-input-with-qcursorsetpos-results-in-a-twitch
    Author: Steeve
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.