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. Make the cursor on the screen invisible after it has stopped

Make the cursor on the screen invisible after it has stopped

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 2.6k 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.
  • R Offline
    R Offline
    redstoneleo
    wrote on last edited by
    #1

    first, sorry for my poor english !

    I want to make the cursor on the screen become invisible after it has stopped moving for 10s. I think this problem can be solved easily if there is a signal like positionChanged(QPoint lastPos , QPoint currentPos) existed,lastPos means the last position of the cursor (hot spot) of the primary screen in global screen coordinates, currentPos means the current position, this signal should be emitted once the cursor stopped moving .Note the Mouse move events here should occur even when a mouse button is not pressed down, i.e. there is mouse tracking with cursor.In Qt, mouse tracking could be enabled with QWidget::setMouseTracking(), however my problem is not restricted to Qt, it is system wide, I want to do this on Windows now ,anyone knows how to enable mouse tracking here ?
    any other solution is also welcome !

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Please have a look at the documentation of class "QCursor":http://qt-project.org/doc/qt-5/QCursor.html. It is possible to obtain the coordinates of the cursor in global screen coordinates using method "pos()":http://qt-project.org/doc/qt-5/qcursor.html#pos. The same class allows you to change the shape or the cursor or to create a cursor with custom image.

      http://anavi.org/

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redstoneleo
        wrote on last edited by
        #3

        yes,I konw it ,the problem I am facing is how to detect the motion of the cursor on the screen,any idea ?
        [quote author="leon.anavi" date="1397839345"]Please have a look at the documentation of class "QCursor":http://qt-project.org/doc/qt-5/QCursor.html. It is possible to obtain the coordinates of the cursor in global screen coordinates using method "pos()":http://qt-project.org/doc/qt-5/qcursor.html#pos. The same class allows you to change the shape or the cursor or to create a cursor with custom image.[/quote]

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andreyc
          wrote on last edited by
          #4

          I would try to use a
          @
          QTimer
          @
          Run it each 10 seconds and compare the screen coordinates with the previous QTimer::timeout signal.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            leon.anavi
            wrote on last edited by
            #5

            [quote author="andreyc" date="1397882114"]I would try to use a
            @
            QTimer
            @
            Run it each 10 seconds and compare the screen coordinates with the previous QTimer::timeout signal.
            [/quote]

            Yes, this is a simple and nice idea but it seems not very precise. The approach using a QTimer just to check mouse coordinates on each 10s will check whether the mouse has been moved in the last 10s but it will not detect whether the mouse has not been moved for 10s. I hope you understand the difference which I try to explain :)

            Since @redstoneleo is trying to implement a solution for windows he can combine Qt source code with hook to the Windows APIs and to handle "WM_MOUSEMOVE":http://msdn.microsoft.com/en-us/library/windows/desktop/ms645616(v=vs.85).aspx. Here are a couple of examples:

            • "System-wide events and Qt":http://davor.no-ip.com/blog/2010/11/24/system-wide-events-and-qt/
            • "Qt global mouse listener":http://stackoverflow.com/questions/20401896/qt-global-mouse-listener

            http://anavi.org/

            1 Reply Last reply
            0
            • R Offline
              R Offline
              redstoneleo
              wrote on last edited by
              #6

              I want to hide system cursor for 10s for some reason ,but I found

              cursor.setShape(Qt.BlankCursor)

              can only hide mouse cursor that is associated with QWidgets ,not in system wide ,i.e. when mouse cursor is hovering on QWidgets, it is invisible ,otherwise it is visible ,so is there any way to hide system cursor in system wide?

              1 Reply Last reply
              0
              • U Offline
                U Offline
                utcenter
                wrote on last edited by
                #7

                You need to use the OS API for this.

                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