PyQt: keyPressEvent and keyReleaseEvent - holding press without debounce

后端 未结 1 1471
难免孤独
难免孤独 2021-01-15 23:33

I want implement a QDialog, in which a key is pressed for some time (seconds) and is released afterwards.

I tried doing this with keyPressEvent

1条回答
  •  北海茫月
    2021-01-16 00:00

    You need to use isAutoRepeat:

    def keyReleaseEvent(self, eventQKeyEvent):
        key = eventQKeyEvent.key()
        if key == 54 and not eventQKeyEvent.isAutoRepeat():
            print('released')
    

    0 讨论(0)
提交回复
热议问题