I'm trying to make a trigger for the Ok button in my application The current code I tried was this:
self.okPushButton.setShortcut("ctrl+Enter")
However, it doesn't work, which kind of makes sense. I tried looking up some key sequences here, but, again, a similar issue if I try with the shift
or alt
keys.
How can I trigger the OkButton with ctrl+Enter
According to the docs:
Qt.Key_Enter 0x01000005 Typically located on the keypad.
That is to say when you set Enter
we refer to the key that is on the numeric keypad.
But if you want to use the default enter you must use Return
.
self.okPushButton.setShortcut("Ctrl+Return")
# seq = QKeySequence(Qt.CTRL+Qt.Key_Return)
# self.okPushButton.setShortcut(seq)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With