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 does ui->textEdit_35->grabKeyboard(); do ?
Forum Updated to NodeBB v4.3 + New Features

what does ui->textEdit_35->grabKeyboard(); do ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 466 Views 2 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I am looking for a real live example using grabKeyboard();
    C/C++ preferred

    Christian EhrlicherC 1 Reply Last reply
    0
    • A Anonymous_Banned275

      I am looking for a real live example using grabKeyboard();
      C/C++ preferred

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AnneRanch what does ui->textEdit_35->grabKeyboard(); do ?

      According to the documentation:

      This widget receives all keyboard events until releaseKeyboard() is called; other widgets get no keyboard events at all. Mouse events are not affected. Use grabMouse() if you want to grab that.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        ui->textEdit_35->grabKeyboard()

        will tell Qt that all keyboards should go to the widget that calls it. Even if the focus is changed so keyboard input will no longer follow focus but stay on the widget.

        To go back to normal, one has to call releaseKeyboard()

        to use use it simply call
        widget->grabKeyboard();
        and then later to release it, call
        widget->releaseKeyboard();

        Its not so often used outside of game like navigation where all keys should go to the controller.

        A 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          ui->textEdit_35->grabKeyboard()

          will tell Qt that all keyboards should go to the widget that calls it. Even if the focus is changed so keyboard input will no longer follow focus but stay on the widget.

          To go back to normal, one has to call releaseKeyboard()

          to use use it simply call
          widget->grabKeyboard();
          and then later to release it, call
          widget->releaseKeyboard();

          Its not so often used outside of game like navigation where all keys should go to the controller.

          A Offline
          A Offline
          Anonymous_Banned275
          wrote on last edited by
          #4

          @mrjj So in not so techie words - if my mouse is positioned in QEdiText widget I can type in and get "textChanged " SIGNAL.
          It is not that easy, but I can process the "changing text".

          So what is the difference in using grab keyboard ?

          ( I did ask for an example code ...)

          mrjjM 1 Reply Last reply
          0
          • A Anonymous_Banned275

            @mrjj So in not so techie words - if my mouse is positioned in QEdiText widget I can type in and get "textChanged " SIGNAL.
            It is not that easy, but I can process the "changing text".

            So what is the difference in using grab keyboard ?

            ( I did ask for an example code ...)

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @AnneRanch

            If you use grabkeyboard on a widget then all keys go to that one, even if you click another widget and start typing.

            its hard to give code example as its really just is

            widget->grabKeyboard();
            
            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