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. What is grabKeyboard, grabMouse,... ?
Forum Updated to NodeBB v4.3 + New Features

What is grabKeyboard, grabMouse,... ?

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

    hi!
    what is grabKeyboard, grabMouse, releaseKeyboard, releaseMouse functions? are they events? what is their difference from keyPressEvent ,... ?
    can you show me an example of using them? I searched them in documentation but found nothing!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Just to be sure, did you miss these

      "grabKeyBoard":http://qt-project.org/doc/qt-5/qwidget.html#grabKeyboard
      "releaseKeyBoard":http://qt-project.org/doc/qt-5/qwidget.html#releaseKeyboard
      "grabMouse":http://qt-project.org/doc/qt-5/qwidget.html#grabMouse
      "releaseMouse":http://qt-project.org/doc/qt-5/qwidget.html#releaseMouse

      ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        NarimanN2
        wrote on last edited by
        #3

        I saw those but still didn't get that! I need some example to learn how they work!

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Call grabMouse on a widget and only that widget will receive mouse events (mouseMoves etc.), the same applies for grabKeyboard.

          This means that the other widgets from your application will not get any mouse/keyboard event until you call the corresponding release function. They are only useful in a handful of cases.

          The best way to see what it does is to create a little application containing some controls like QSlider, QSpinBox etc. and call the grabXXX functions on one of them.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mark Bush
            wrote on last edited by
            #5

            if a widget grabkeyboard, then I delete it while it doesn't releasekeyboard. So, now,who get keyboard event?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi and welcome to devnet,

              Did you try to implement a test application to check what happens ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved