Here is some code that reproduces my 'error' so to speak:
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QKeySequence
from PyQt5.QtWidgets import (QShortcut, QTextEdit, QApplication)
app = QApplication([])
wid = QTextEdit()
wid.show()
short = QShortcut(QKeySequence(Qt.Key_F2), wid)
short.activated.connect(sys.exit)
app.exec()
Hitting F2 , as expected, shuts the program down. If I were to use other keys as an argument, such as QKeySequence(Qt.Key_Control) or QKeySequence(Qt.Key_Control + Qt.Key_F2), nothing happens when I hit said keys upon launching the program
I can't seem to figure out what about them prevents them from triggering the shortcut. From the reading on other SO threads I've gone through about shortcuts, some state that the widget in question might not be focused. I've made sure my widgets were focused , but despite that, the shortcuts don't trigger when I use such keys
Some state that a widget's child's keyPressEvent might eat up the shortcut. This confuses me. I did go through the docs, and shortcutEvents happen to be their own unique individual event. I don't understand why a widget's keyPressEvent handler might choose to handle a shortcutEvent passed to it
I believe it has something to do with the keys I specified for the shortcuts themselves, but I can't quite put my finger on it. Sure, just using F2 as the shortcut IS an option, but I'd really like to allow for the pressing of say, Shift + F2 or Control + F2 as a shortcut, which isn't working for some odd reason