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. Block keyboard in QDialog
Forum Updated to NodeBB v4.3 + New Features

Block keyboard in QDialog

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.3k 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.
  • A Offline
    A Offline
    ARASHz4
    wrote on last edited by
    #1

    Hi
    how to block keys like 'Esc' , 'up' , 'Down' , 'Right' ...... on keyboard?
    like i pressed 'Esc' key dialog don't close

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

      Hi
      Block for a Dialog or for whole application ?

      In many cases, using event filter might work good.

      https://wiki.qt.io/How_to_catch_enter_key

      or for just dialog

      MyDialog::keyPressEvent(QKeyEvent *e) {
          if(e->key() != Qt::Key_Escape)
              QDialog::keyPressEvent(e);
          else {/* minimize */}
      }
      
      1 Reply Last reply
      2
      • A Offline
        A Offline
        ARASHz4
        wrote on last edited by ARASHz4
        #3

        I want use the keys but don't effect on Dialog
        I want set shortcut keys for my app like Qt Creator in Option>Environment>Keyboard when Record button is clicked keys not effect on Dialog & any key is pressed show in a QLineEdit
        How can i do this?

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Create event filter to filter required keys and install filter on ur dialog which is not supposed to receive the keys. This filter you can install for any widget you want.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          2

          • Login

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