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. GrabMouse() without a window?
Forum Updated to NodeBB v4.3 + New Features

GrabMouse() without a window?

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

    Ok so I've written a a little app that allows users to click at one point on the screen and drag their mouse to another point and it will screenshot everything withing those 4 points. Now Current the app loads and user clicks a button that invokes this.grabMouse() etc...

    I was hoping for a way to fire up the application and have it grab the mouse and hide itself right away. I've been unsuccessful due to the fact that grabMouse() seems to need an object and the main window has to be drawn and loaded etc... before grabMouse() will work.

    any help, ideas etc.. would be wonderful.

    thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      you could make your main window of a minimal size and move iot out of the visibale area (move(-200, -200)).

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

        If you're working on a Windows host imho it's better to use the WinAPI for this:

        Use the GetCursorPos function for the position:
        http://msdn.microsoft.com/en-us/library/ms648390.aspx

        And GetKeyState for the Click-State:
        http://msdn.microsoft.com/en-us/library/ms646301(VS.85).aspx
        (VK_LBUTTON => List: http://msdn.microsoft.com/en-us/library/dd375731(VS.85).aspx)

        Taking a screenshot is done with GetWindowDC and BitBlt
        (Search it on msdn)

        Hope it helps you

        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