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. Cursor handling
Forum Updated to NodeBB v4.3 + New Features

Cursor handling

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 7 Posters 1.1k Views 3 Watching
  • 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.
  • O Offline
    O Offline
    Oumayma
    wrote on last edited by
    #1

    How could I have the cursor blocked in an area of ​​my application and when I do not use the application I can unlock it?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Only with OS specific stuff, not possible with Qt

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      HoMaH 1 Reply Last reply
      1
      • Kent-DorfmanK Offline
        Kent-DorfmanK Offline
        Kent-Dorfman
        wrote on last edited by
        #3

        There is no "cursor" in a Qt GUI app, except in the text edit class of type widgets.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stryga42
          wrote on last edited by
          #4

          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.

          O 1 Reply Last reply
          0
          • S stryga42

            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.

            O Offline
            O Offline
            Oumayma
            wrote on last edited by
            #5

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

            jsulmJ S 2 Replies Last reply
            0
            • O Oumayma

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

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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

              https://doc.qt.io/qt-5/qwidget.html#setFocus

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • O Oumayma

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

                S Offline
                S Offline
                stryga42
                wrote on last edited by
                #7

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

                Kent-DorfmanK jeremy_kJ 2 Replies Last reply
                0
                • S stryga42

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

                  Kent-DorfmanK Offline
                  Kent-DorfmanK Offline
                  Kent-Dorfman
                  wrote on last edited by Kent-Dorfman
                  #8

                  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

                  1 Reply Last reply
                  0
                  • S stryga42

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

                    jeremy_kJ Offline
                    jeremy_kJ Offline
                    jeremy_k
                    wrote on last edited by
                    #9

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

                    Asking a question about code? http://eel.is/iso-c++/testcase/

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      Only with OS specific stuff, not possible with Qt

                      HoMaH Offline
                      HoMaH Offline
                      HoMa
                      wrote on last edited by
                      #10

                      @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

                      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