I have an action with a shortcut associated and I want to identify if my action was triggered by clicking or using the shortcut.
ChatGPT told me that I can use the event parameter passed to my function, but it is a bool instead of QActionEvent. It provided this sample code:
if isinstance(event, QActionEvent) and event.isShortcut():
My action:
curr_shortcut = app_settings.value("shortcut", defaultValue="W")
ankipa_action = QAction("AnkiPA...", mw)
ankipa_action.triggered.connect(main_dialog)
ankipa_action.setShortcut(QKeySequence(f"Ctrl+{curr_shortcut}"))
mw.form.menuTools.addAction(ankipa_action)