Important: Please read the Qt Code of Conduct -

Screen rotation does not handle mouse clicks properly

  • We have an application running on an embedded Linux platform using EGLFS. We were using Qt 5.3.1 up until now, and had implemented a workaround for this bug: Now, I've updated our application to use Qt 5.8, where this bug should be fixed. We also just switched from using Widgets to using QML.

    In our platform, the display is mounted upside-down due to physical constraints. In the QML, the rotation property of our top-level "window" is set to 180. This properly rotates the graphical image so it appears to be correct. In addition, I'm also setting the following environment variables to get the resistive touch sense and mouse hardware cursors to appear correctly:

                export QT_QPA_EGLFS_ROTATIONQT_QPA_GENERIC_PLUGINS=evdevtouch:/dev/input/touchscreen0
                export QT_QPA_EVDEV_TOUCHSCREEN_PARAMETERS=/dev/input/touchscreen0:rotate=180
                export QT_QPA_EGLFS_ROTATION=180

    With the exception of when the mouse is actually clicked, everything works as it should. The image is rotated 180 degrees, the mouse cursor look correct and moves as expected, and touches are registered properly.

    However, when the mouse is clicked, the coordinates are "backwards" - a click in the upper-left corner appears to the application to be a click to the lower-right (and vice-versa). It's as if the "click coordinates" are not rotated, while everything else is.

    I've found the spot in the Qt code where I could fix this by simply manipulating the coordinates, but this doesn't seem like the right solution. I believe I've either got something set up incorrectly, or there is still a bug in the rotation stuff in Qt.

    I should mention that if I do NOT rotate my UI by using the rotate parameter in QML, the mouse clicking seems to work fine ... Almost like when QML rotates the UI, it rotates how it draws, now how the mouse works.

    (NB: The documentation says that QT_QPA_EGLFS_ROTATION only rotates Widget apps and the mouse cursor, and Quick needs to do its own rotation. I need the mouse cursor to be correct, hence QT_QPA_EGLFS_ROTATION)

    Any ideas?

  • Actually, I have a correction to all that:

    When I rotate "the mouse" with QT_QPA_EGLFS_ROTATION=180, the coordinates of the mouse events rotates with the mouse cursor.

    When I rotate my QML, it ALSO rotates the mouse events, effectively undoing the 180 degree rotation for the mouse clicks.

    It seems I cannot have both of these at the same time ... but I need both!

  • @Steve172 Did you get it towork?
    I am on the same boat as you now.
    Mouse cursor rotates but the click event doenst.

Log in to reply