Congratulations to our 2022 Qt Champions!

How to read keys and how to disable keys for embedded application?

  • hi all,

    i want to create an application in which i want to read the pressed keys on my device and for some part of application i want to disable some of the keys like e.g. shift key, space key etc. (from physical keyboard of device)
    i am able to read keys like enter, space, shift backspace from my device using key events (as given in qnamespace.h values) but not able to disable desired keys like space n shift.
    suppose there is simple screen with lineedit and a push button, so when the cursor is in lineedit all keys other than alpha n numbers should not work and when pushbutton is selected then only enter key should work.
    but in my application the pushbutton is pressed by space key instead of enter key also while entering in lineedit if i press shift bymistake the it stops taking input untill you again press it.
    want to solve this issues...can anybody help me with this
    thanks in advance....

  • Hey, if you want to disable certain keys for your input you could simply use an input mask or validator on the QLineEdit?
    check the doc for QLineEdit ::setInputMask and QLineEdit::setValidator

    key press events should be delivered to the widget that has the active focus, so I don't know why that ins't working like you want it to be?

Log in to reply