Results 1 to 8 of 8

Thread: how can I get the handle of the window when the mouse is move

  1. #1
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how can I get the handle of the window when the mouse is move

    how can I get the handle of the window when the mouse is move,
    I want to get the handle of the window and get the window's coordinateof the upper left corner and coordinate of the downer right corner .
    Last edited by jacek; 26th June 2008 at 22:47. Reason: fixed font

  2. #2
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how can I get the handle of the window when the mouse is move

    You can use QWidget::geometry() or QWidget::frameGeometry() to get the Coordinate of Widget and QWidget::mapToGlobal() to convert them in Global Coordinates.

    What means
    how can I get the handle of the window when the mouse is move
    ?

    You can reimplement QWidget::mouseMoveEvent() to catch mouse movement and use QWidget::setMouseTracking() to set ON mouse tracking properties
    A camel can go 14 days without drink,
    I can't!!!

  3. #3
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how can I get the handle of the window when the mouse is move

    Quote Originally Posted by mcosta View Post
    You can use QWidget::geometry() or QWidget::frameGeometry() to get the Coordinate of Widget and QWidget::mapToGlobal() to convert them in Global Coordinates.

    What means ?

    You can reimplement QWidget::mouseMoveEvent() to catch mouse movement and use QWidget::setMouseTracking() to set ON mouse tracking properties
    thanks
    but the mouse is out side the widget ,and the mouseMoveEvent() can track where is the mouse

  4. #4
    Join Date
    Jan 2006
    Location
    Napoli, Italy
    Posts
    621
    Thanks
    5
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how can I get the handle of the window when the mouse is move

    You are right.
    But if you press a mouse button when pointer is on the widget and you move the pointer outside the widget you receive mouseMoveEvent.

    You can grab the mouse with QWidget::grabMouse()
    A camel can go 14 days without drink,
    I can't!!!

  5. #5
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how can I get the handle of the window when the mouse is move

    But I want get the handle when the mouse clicked out side the window
    Or I just move the mouse out side the window not press the mouse and move

  6. #6
    Join Date
    Feb 2008
    Posts
    51
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how can I get the handle of the window when the mouse is move

    Hi,

    Can you explain your problem in details? I would like to know what are you trying to achieve so that I can help you in better way.

    If that window is created by your application then you can get it easily with QApplication::allWidgets () but before that you have to grab the mouse and check whether mouse position lies within geometry of any window.

    If you want to obtain the mouse press event and the window for which it is intended then you have to hook the mouse events with the help of other api's. For that you may have to depend on platform specific api's.

  7. The following user says thank you to Sandip for this useful post:

    duduqq (13th July 2008)

  8. #7
    Join Date
    Apr 2008
    Posts
    41
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how can I get the handle of the window when the mouse is move

    Quote Originally Posted by Sandip View Post
    Hi,

    Can you explain your problem in details? I would like to know what are you trying to achieve so that I can help you in better way.

    If that window is created by your application then you can get it easily with QApplication::allWidgets () but before that you have to grab the mouse and check whether mouse position lies within geometry of any window.

    If you want to obtain the mouse press event and the window for which it is intended then you have to hook the mouse events with the help of other api's. For that you may have to depend on platform specific api's.
    yes ,i want to obtain the mouse press event when the mouse move or press at the desktop or other window,how can i get the handle with the help of the api,can you get me some code,thank you very much.

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how can I get the handle of the window when the mouse is move

    J-P Nurmi

Similar Threads

  1. How do I natively move a QWidget top-level window?
    By codeslicer in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2008, 21:08
  2. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34
  3. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 08:41
  4. Replies: 2
    Last Post: 24th July 2006, 18:36
  5. Move window in Clone Mode
    By ultrabrite in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2006, 18:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.