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



  • 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?



  • // 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)



  • @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)...



  • 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.



  • @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



  • On the VM, try to disable the mouse integration.



  • @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.


  • Qt Champions 2016

    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"



  • @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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.