I am building a UI with Qt Designer and I want buttons to perform different actions with different modifiers. So I thought I could call functions with dynamic string properties that would perform the action depending on the modifier.
If anyone knows a simpler way to do this I would appreciate it very much.
here's another approach using bit operators, that avoids getting into many combos.
It looks like all you need to do is check the keyboardModifiers in your button handler, and select a different action as appropriate. The various modifiers can be OR'd together in order to check for multi-key combinations:
PyQt5:
PyQt4:
This is late reply but this is the solution that I found.
I was trying to handle multiple keys pressed at the same time (e.g. A and W or W and D). The solution below works with multiple keys being pressed at the same time (including Ctrl, Shift, Alt, etc). I hope someone else can find it useful.
Go here for the original discussion of this solution: How to get multiple key presses in single event?