PDA

View Full Version : action with shortcut triggers in parent



tuli
4th March 2022, 19:46
Hi,

This is in Python 5.12, but the same applies to C++. I am writing a plugin for an C++ application that embeds python and PySide.
All is working well, except when I register actions with a shortcut in my QTableView widget (tableview->addAction()), then the shortcut triggers in the parent application, rather than in my tableview. I have tried Qt::ShortcutContext, but they dont make a difference.


I can hack up something with an eventFilter, but certainly there must be a better way?


edit: ok, it only happens if a certain widget of the parent application has focus. so i am guessing they are doing funky stuff in event listeners or something and my only choice is to step down on that level too.

franco.amato
14th March 2022, 20:58
How are you creating que QAction?

The QWidget::addAction(QAction *action) documentation says that "The ownership of action is not transferred to this QWidget"

Sincerely