Cursor handling
-
Only with OS specific stuff, not possible with Qt
-
There is no "cursor" in a Qt GUI app, except in the text edit class of type widgets.
-
Do you mean your mouse pointer or a true text cursor? Because text cursors are just a way of displaying the input focus. Then your question would actually ask for some sort of focus manipulation. Please explain.
-
@stryga42 I mean the mouse pointer, but also if you inform me how I can control the input focus of the cursor it would help me.
Thanks.@Oumayma said in Cursor handling:
but also if you inform me how I can control the input focus of the cursor it would help me
-
@stryga42 I mean the mouse pointer, but also if you inform me how I can control the input focus of the cursor it would help me.
Thanks.@Oumayma
No reasonable graphics system would allow you to lock the mouse pointer itself within a given area. You can create you own "software pointer" which follows the mouse pointer. Older 2D CAD software used this style. Pro: This software pointer is under your full control. Con: It will lag slightly behind the true mouse pointer and you have to program it yourself. E,g, based on QWidget::mouseMoveEvent . -
@Oumayma
No reasonable graphics system would allow you to lock the mouse pointer itself within a given area. You can create you own "software pointer" which follows the mouse pointer. Older 2D CAD software used this style. Pro: This software pointer is under your full control. Con: It will lag slightly behind the true mouse pointer and you have to program it yourself. E,g, based on QWidget::mouseMoveEvent .what @stryga42 said...however, the pointer is certainly under your control within a given window. Under X11 control you can redefine the pointer bitmap so that it is invisible, or even ignore events while it is inside a given region....it is common to hide the pointer on POS applications that exist on a touchscreen. we don't want a visible mouse pointer if the user is pushing touch button points on a screen
-
@Oumayma
No reasonable graphics system would allow you to lock the mouse pointer itself within a given area. You can create you own "software pointer" which follows the mouse pointer. Older 2D CAD software used this style. Pro: This software pointer is under your full control. Con: It will lag slightly behind the true mouse pointer and you have to program it yourself. E,g, based on QWidget::mouseMoveEvent .@stryga42 said in Cursor handling:
@Oumayma
No reasonable graphics system would allow you to lock the mouse pointer itself within a given area.Several of the vmware products have modes that trap the cursor within a VM's window under macOS and X11 on Linux. There are games that do it as well, although I can't remember any names at the moment.
The QCursor::setPos() functions are supposed to accomplish moving the cursor. You could filter MouseMove events and call QCursor::setPos() when appropriate. My test case using Qt 5.15.2 didn't work, but that's probably my error. Even if it did work, the cursor might be well outside of the window by the time the event is processed by the application.
https://bugreports.qt.io/browse/QTBUG-50168 asks for the ability to proactively restrict the cursor instead of retroactively repositioning it when the windowing system announces a move that has already occurred. The initial request was almost 5 years ago, and doesn't appear to have progressed beyond a few proposed changes.
-
Only with OS specific stuff, not possible with Qt
@Christian-Ehrlicher yes, exactly. On Windows for example there is the ClipCursor function ...
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-clipcursor?redirectedfrom=MSDN