Pre
I searched other Questions and couldn't find out the solution.
I want to execute Tab key and Shift operation simultaneously because I want to add a new performance by pressing tab key.I know the Shiftmodifier enum is good. But it doesn't work when the key is Tab key.Do you know how to control it? On the other hand,Controlmodifier works well.
When I pushed Tab key
tab only
When I pushed Tab & Control Key
tab & Control
When I pushed Any Key except for Tab & Shift Key
print("tab & any key except for tab key")
When I pushed Tab & Shift Key
No Response... Why?
Sample Code
from PySide import QtGui
from PySide import QtCore
import sys
class TSEditer(QtGui.QTextEdit):
def __init__(self,parent=None):
super(TSEditer,self).__init__(parent=None)
def keyPressEvent(self,event):
if event.key() == QtCore.Qt.Key_Tab and event.modifiers() == QtCore.Qt.ControlModifier:
print("tab & control")
elif event.key() == QtCore.Qt.Key_Tab and event.modifiers() == QtCore.Qt.ShiftModifier:
print("tab & shift")
elif event.key() == QtCore.Qt.Key_A and event.modifiers() == QtCore.Qt.ShiftModifier :
print("tab & any key except for tab key")
elif event.key() == QtCore.Qt.Key_Tab:
print("tab only")
return QtGui.QTextEdit.keyPressEvent(self,event)
def main():
try:
QtGui.QApplication([])
except Exception as e:
print(15,e)
ts = TSEditer()
ts.show()
sys.exit(QtGui.QApplication.exec_())
if __name__ == "__main__":
main()