Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is QCursor::setPos() not working on MacOS X?

Is QCursor::setPos() not working on MacOS X?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 3.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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi,
    In my app, I am doing something like this to position the mouse pointer to where I want:

    const QCursor c = this->cursor();
    c.setPos(QPoint(x, y));
    setCursor(c);
    

    This works just fine on Windows. However, it does not work on MacOS X: it does nothing.

    I couldn't find any platform restrictions on the usage of the setPos method other than that this function does nothing on platforms without a windowing system or cursor system. Since MacOS X has a windowing system and a cursor system, why does the above not seem to work?

    1 Reply Last reply
    1
    • M mpergand

      On the VM, try to disable the mouse integration.

      DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by
      #7

      @mpergand said in Is QCursor::setPos() not working on MacOS X?:

      On the VM, try to disable the mouse integration

      Thanks! I disabled VMWare Tools (by uninstalling them in the MacOS X guest), and the minimal test program above works now. So the issue is definitely VMware-related.

      However, I couldn't find any other way to disable this. I have tried adding

      vmmouse.present = "FALSE"

      in the .vmx file, as suggested somewhere, but that has no effect.

      Since the VMware tools are quite useful otherwise, if you know of any other way to disable mouse integration (I use the latest VM Ware Player), then please do let me know!

      Thanks again.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mpergand
        wrote on last edited by
        #2
        // cursor at the top left corner of the widget
        QCursor::setPos(mapToGlobal(QPoint(0,0)));
        // cursor at top left corner of the window
        QCursor::setPos(window()->pos());
        

        works as expected on Mac (10.9.5, Qt 5.7.1)

        DiracsbracketD 1 Reply Last reply
        0
        • M mpergand
          // cursor at the top left corner of the widget
          QCursor::setPos(mapToGlobal(QPoint(0,0)));
          // cursor at top left corner of the window
          QCursor::setPos(window()->pos());
          

          works as expected on Mac (10.9.5, Qt 5.7.1)

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by
          #3

          @mpergand
          Thanks. I'm on Mac OS X 10.12 (Virtual machine inside Windows 10 Host) and Qt 5.9.4. In a minimal app of only 1 button, and the setPos() line, the only thing that happens with your code vs. mine is that the cursor changes to a 45deg slanted double arrow line (the window resize drag-cursor)...

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mpergand
            wrote on last edited by
            #4

            What do you want to do exactly ?

            QCursor::setPos(QPoint(200,100));
            position the cursor at 200,100 in screen coordinates.
            If you want to position the cursor over a widget inside your window, you need to use mapToGlobal() to get the screen position.

            DiracsbracketD 1 Reply Last reply
            0
            • M mpergand

              What do you want to do exactly ?

              QCursor::setPos(QPoint(200,100));
              position the cursor at 200,100 in screen coordinates.
              If you want to position the cursor over a widget inside your window, you need to use mapToGlobal() to get the screen position.

              DiracsbracketD Offline
              DiracsbracketD Offline
              Diracsbracket
              wrote on last edited by Diracsbracket
              #5

              @mpergand said in Is QCursor::setPos() not working on MacOS X?:

              If you want to position the cursor over a widget inside your window, you need to use mapToGlobal() to get the screen position.

              I'm well aware of that, and as I wrote in my post: it works perfectly fine in my Windows app, so I think I understand the difference between widget-local and global coordinates.

              Whatever QPoint(x, y) I use, the mouse pointer is not moved to that position in my MacOX VM

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mpergand
                wrote on last edited by
                #6

                On the VM, try to disable the mouse integration.

                DiracsbracketD 1 Reply Last reply
                3
                • M mpergand

                  On the VM, try to disable the mouse integration.

                  DiracsbracketD Offline
                  DiracsbracketD Offline
                  Diracsbracket
                  wrote on last edited by
                  #7

                  @mpergand said in Is QCursor::setPos() not working on MacOS X?:

                  On the VM, try to disable the mouse integration

                  Thanks! I disabled VMWare Tools (by uninstalling them in the MacOS X guest), and the minimal test program above works now. So the issue is definitely VMware-related.

                  However, I couldn't find any other way to disable this. I have tried adding

                  vmmouse.present = "FALSE"

                  in the .vmx file, as suggested somewhere, but that has no effect.

                  Since the VMware tools are quite useful otherwise, if you know of any other way to disable mouse integration (I use the latest VM Ware Player), then please do let me know!

                  Thanks again.

                  1 Reply Last reply
                  0
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    Hi
                    https://superuser.com/questions/477653/how-can-i-have-a-windows-7-vmware-guest-without-mouse-support

                    You might be able to do it with preference.ini

                    Alternatively, grab a trial work station and set it.
                    Even if no GUI for it. player respects all settings done by "big brother"

                    DiracsbracketD 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      Hi
                      https://superuser.com/questions/477653/how-can-i-have-a-windows-7-vmware-guest-without-mouse-support

                      You might be able to do it with preference.ini

                      Alternatively, grab a trial work station and set it.
                      Even if no GUI for it. player respects all settings done by "big brother"

                      DiracsbracketD Offline
                      DiracsbracketD Offline
                      Diracsbracket
                      wrote on last edited by Diracsbracket
                      #9

                      @mrjj said in Is QCursor::setPos() not working on MacOS X?:

                      You might be able to do it with preference.ini

                      I tried adding the following to %USER%\AppData\Roaming\VMware\preferences.ini

                      pref.vmmouse.present = "FALSE"
                      pref.motionUngrab = "FALSE"
                      

                      This did not work. For good measure I also have in my .vmx file:

                      vmmouse.present = "FALSE"
                      motionUngrab = "FALSE"
                      

                      That also doesn't work. I am user VMware Player, and there are no many options available in the Preferences dialog of the program as in VMware Workstation it seems. I'll try with VMware Workstation Pro. Downloading it now.

                      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