Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt Mouse Pointer Rotation
Forum Update on Monday, May 27th 2025

Qt Mouse Pointer Rotation

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
12 Posts 3 Posters 7.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michaelL
    wrote on 15 Feb 2017, 15:11 last edited by
    #1

    Hi,

    i am using Qt5.5 on an embedded linux and depending on the position of the screen i am rotating my QML application.
    The probem i am facing is to rotate the mouse pointer too.
    Once its 180° rotated, the mouse pointer uses its default coordinates like on 0° orientation.
    Is there any chance to rotate the pointer ?

    M 2 Replies Last reply 15 Feb 2017, 15:43
    0
    • M michaelL
      15 Feb 2017, 15:11

      Hi,

      i am using Qt5.5 on an embedded linux and depending on the position of the screen i am rotating my QML application.
      The probem i am facing is to rotate the mouse pointer too.
      Once its 180° rotated, the mouse pointer uses its default coordinates like on 0° orientation.
      Is there any chance to rotate the pointer ?

      M Offline
      M Offline
      matthew.kuiash
      wrote on 15 Feb 2017, 15:43 last edited by
      #2

      @michaelL OK, I haven't tried this (and I assume you REALLY want to do this!) but here's my hypothesis

      • Use QCursor getCursor() on your main window
      • Get the Pixmap from that Cursor
      • Now create a rotated pixmap like this…
        • QPixmap rotated_pixmap = cursor.getPixmap().transformed(QTransform().rotate(180));
      • Then set the cursor again QCursor newCursor(rotated_cursor)
        • QCursor rotated_cursor(rotated_pixmap)
        • mainWindow->setCursor(rotated_cursor)

      You should vertically mirror the hot spot too.

      WARNING! Your system may only support mask/bitmap cursors in which case the above will work but with mods to use QBitmap and QCursor::mask and QCursor::bitmap.

      Good luck. Never tried this! Interested to see if it works.

      The legendary cellist Pablo Casals was asked why he continued to practice at age 90. "Because I think I'm making progress," he replied.

      1 Reply Last reply
      0
      • M michaelL
        15 Feb 2017, 15:11

        Hi,

        i am using Qt5.5 on an embedded linux and depending on the position of the screen i am rotating my QML application.
        The probem i am facing is to rotate the mouse pointer too.
        Once its 180° rotated, the mouse pointer uses its default coordinates like on 0° orientation.
        Is there any chance to rotate the pointer ?

        M Offline
        M Offline
        matthew.kuiash
        wrote on 15 Feb 2017, 16:00 last edited by
        #3

        @michaelL OK, I tried it on my Mac and it works...

        Here's the code for DL http://kuiash.net/dokuwiki/doku.php?id=flip_mouse_cursor

        The legendary cellist Pablo Casals was asked why he continued to practice at age 90. "Because I think I'm making progress," he replied.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          michaelL
          wrote on 16 Feb 2017, 06:37 last edited by
          #4

          @matthew-kuiash My application is running in QML, i think this could work for the cursor icon but what happens to its movement?
          When i move the mouse pointer downwards, it goes upwards and so on. I have to invert the mouse cursor coordinates too.
          If i do this the whole time, my one core embedded CPU will be overloaded with calculation and the application will be very slow i think.
          I dont know if there is a simple way on doing this directly on linux or if there is a Qt Mouse event input handler so it does invert it on every input event for me.

          M 1 Reply Last reply 16 Feb 2017, 07:37
          0
          • M michaelL
            16 Feb 2017, 06:37

            @matthew-kuiash My application is running in QML, i think this could work for the cursor icon but what happens to its movement?
            When i move the mouse pointer downwards, it goes upwards and so on. I have to invert the mouse cursor coordinates too.
            If i do this the whole time, my one core embedded CPU will be overloaded with calculation and the application will be very slow i think.
            I dont know if there is a simple way on doing this directly on linux or if there is a Qt Mouse event input handler so it does invert it on every input event for me.

            M Offline
            M Offline
            matthew.kuiash
            wrote on 16 Feb 2017, 07:37 last edited by
            #5

            @michaelL Dude! Pain! Well, these kind of problems are typically solved at driver or window manager level not in applications. You could just take complete control I guess and do all the work yourself in your app. I wouldn't say it would take too much time as I used to have to do the same on 8Mhz 286 machines. But yes, it'll take time.

            If you're using X there seem to be a solution. I found an Ubuntu thread about inverting mouse axis here...

            http://askubuntu.com/questions/16480/inverted-mouse-axis-on-a-ubuntu-live-usb

            If you're not using X, well, there are several places you could invert. Application, Qt Platform plugin (that is produce you own platform library and put this functionality in there or down in the OS drivers.

            The legendary cellist Pablo Casals was asked why he continued to practice at age 90. "Because I think I'm making progress," he replied.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              michaelL
              wrote on 16 Feb 2017, 09:47 last edited by
              #6

              @matthew-kuiash
              My screen rotates only to 180° and normal orientation is 0°.
              I could make two custom mouse pointer shapes. One is the inverse from the other.
              By default orientation the application doesnt do anything. By 180° orientation i change the mouse pointer shape and change the QCursor position.
              With QCursor:pos() i get a QPointer back and i simply multiply x*-1 and y*-1 and set this new QPointer on the QCursor:setPos().
              The mouse pointer navigation should be inverted too.
              I will try this later on.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                michaelL
                wrote on 16 Feb 2017, 09:59 last edited by
                #7

                @matthew-kuiash
                with x*-1 y*-1 it wont work. I have to change to my display coordinates. So the screen zeros (0,0) have to be the screen resolution (displya.width, display.height). So the moving cursor will be like QPointer(display.width - x, display.height -y), where x and y are the new position coordinates from the mouse pointer.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  michaelL
                  wrote on 17 Feb 2017, 08:09 last edited by
                  #8

                  @matthew-kuiash So i can change the cursor shape and i can change its coordinates.
                  When i move the mouse it goes to where it should be but it appears in its original location too.
                  What i mean is that when the mouse event occurs its too late to change its coordinates by then, because the mouse cursor will be displayed
                  first on the screen and jumps to the movement event.
                  In main i installed an event to detect when the mouse is moving and change its coordinate:
                  if (event->type() == QEvent::MouseMove)
                  {
                  QMouseEvent mouseEvent = static_cast<QMouseEvent>(event);
                  mouse_cursor.set_cursor_position(1280-mouseEvent->pos().x(), 800 -mouseEvent->pos().y());
                  }
                  I also create an Item in QML and had a mous cursor picture in it. It looked and moved like a mouse but it was only an image.
                  I can set the mouse cursor shape to blank so its not displayed and than have my image to mouse cursor to replace him.
                  But how do i disable the mouse to click the buttons, even if its not visible?
                  My QML Item is a Rectangle with an Image in it. How do i make it to click buttons or to be able to interact to MouseAreas?

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    michaelL
                    wrote on 17 Feb 2017, 09:01 last edited by
                    #9

                    I found some interresting documentation:

                    QT_QPA_EGLFS_ROTATION - Specifies the rotation applied to software-rendered content in QWidget-based applications. Supported values are 180, 90, and -90. This does not apply to OpenGL-based windows, including Qt Quick. Qt Quick applications can apply transformations in their QML scene instead. The standard eglfs mouse cursor always takes the value into account, with appropriately positioned and rotated pointer image, regardless of the application type. The special cursor implementations, such as the KMS/DRM backend's hardware cursor, may not support rotation.

                    But why is my mouse also not rotating?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Steve172
                      wrote on 17 Apr 2017, 14:46 last edited by
                      #10

                      You've quite possibly run into this bug, supposedly fixed in Qt 5.8: https://bugreports.qt.io/browse/QTBUG-39959

                      We're using QML, and our display is installed in our hardware upside down. I've successully flipped by ts_lib touch sense and my mouse cursor/mouse movement using the following:

                      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

                      Touch sense works fine, mouse cursor looks fine, moves fine. But mouse clicks use their "unrotated" position ... For example, clicking the the top-right corner of the UI registers as a click in the bottom-left corner. Working on figuring this out now...

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        michaelL
                        wrote on 15 May 2017, 05:44 last edited by
                        #11

                        @Steve172 thanks for your answer. I am still working on Qt5.7.1 but i will upgrade to 5.8 soon and will give it a try.
                        My touch works fine but only mouse rotation is the issue.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          michaelL
                          wrote on 5 Dec 2017, 14:01 last edited by
                          #12

                          @Steve172 did you manage to get it to work?
                          I am using Qt5.9.1 now and set the variables as you said and have the saime issue.
                          Mouse is rotated now but the click coordinates are not rotated/inverted.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved