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. Using QWidget::grabMouse() on Mac
Forum Updated to NodeBB v4.3 + New Features

Using QWidget::grabMouse() on Mac

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.1k 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.
  • O Offline
    O Offline
    OceanHsiao
    wrote on last edited by
    #1

    Hi all,
    I got a problem about QWidget::grabMouse().

    I created my customized widget on a QDialog.
    And I want use the grabMouse() to let my customized widget to catch all mouse event.
    On Windows, the grabMouse() works Ok.
    But, on Mac, it just works fine when the mouse is inside the QDialog,
    but when the mouse moved to the outside frame of QDialog, my customized widget couldn't grab any mouse event.

    I found the QWidget Document notices that:

    Note: (Mac OS X developers) For Cocoa, calling grabMouse() on a widget only works when the mouse is inside the frame of that widget. For Carbon, it works outside the widget's frame as well, like for Windows and X11.

    So, Does it mean I couldn't use the grabMouse() On Mac works fine as well as On Windows?

    If I really want to use the grabMouse() to catch all mouse events when the mouse is outside the frame of QDialog that my customized widget is on, how can I achieve that?

    Many thanks for the help! :)

    1 Reply Last reply
    0
    • N Offline
      N Offline
      newgen23
      wrote on last edited by
      #2

      I have the same problem. As a workaround I tried to "clue" the mouse to the middle of my window with:
      cursor().setPos(mapToGlobal(QPoint(width()/2,height()/2)));

      But since the upgrade to osx lion, this does not work anymore. In fact, the grabMouse() still allows the cursor to "leave" the window. When programming a 3d opengl egoshooter, this it not helpfull at all...

      we need help!

      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