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 there a way I could track my mouse movement outside the widget?
QtWS25 Last Chance

Is there a way I could track my mouse movement outside the widget?

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

    I want to create an app which would track mouse movement outside the widget. For example: when the cursor is moving outside of the widget scope, I will be a able to detect cursor movement. I know how to set the tracking when the cursor is over the widget (EventFilter || MouseMoveEvent).

    Mandruk1331

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      You could take a look at QObject::installEventFilter or QCoreApplication::installNativeEventFilter

      If even the latter does not provide events that are outside our widget, the you would probably have to use system-native code instead of Qt.

      One trick might be to have a fullscreen transparent widget overlaying the whole screen.

      mandruk1331M 1 Reply Last reply
      1
      • A Asperamanca

        You could take a look at QObject::installEventFilter or QCoreApplication::installNativeEventFilter

        If even the latter does not provide events that are outside our widget, the you would probably have to use system-native code instead of Qt.

        One trick might be to have a fullscreen transparent widget overlaying the whole screen.

        mandruk1331M Offline
        mandruk1331M Offline
        mandruk1331
        wrote on last edited by mandruk1331
        #3

        @Asperamanca I have used the EventFilter but it only track mouse activity over the widget, if it's outside the widget then it does not work. I have used WinApi functions:
        Opened it in another thread. The idleTicks variable will go to zero if movement detected if no movement it will increment itself.

        LASTINPUTINFO lii;
        memset(&lii, 0, sizeof(lii));
        lii.cbSize = sizeof(lii);
        while (1){
        GetLastInputInfo(&lii);
        long currTicks = GetTickCount();
        long lastInputTicks = lii.dwTime;
        long idleTicks = currTicks - lastInputTicks;
        }

        Mandruk1331

        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