简体   繁体   中英

pyside - how to capture capital letter (KeyEvent)?

I have understood that letters to capture the event is used keyPressEvent .

def iniciar(self):
    self.resize(730, 500)
    self.setFixedSize(730, 500)
    self.center()
    self.setWindowTitle('Practico 1')
    self.show() 

def center(self):
    qr = self.frameGeometry()
    cp = QtGui.QDesktopWidget().availableGeometry().center()
    qr.moveCenter(cp)
    self.move(qr.topLeft())

def keyPressEvent(self, e):
    if e.key() == QtCore.Qt.Key_A:
        QtGui.QMessageBox.information(self, 'pressed', 'you pressed the letter "a"')                

This way I capture letters either in uppercase or lowercase, but how should I verify a capital letter has been pressed?

You can check uppercase using modifiers. For instance with

if e.key() == QtCore.Qt.Key_A and (e.modifiers() & QtCore.Qt.SHIFT):

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM