Yes, I have. An application-wide context should do it. But it doesn't work. I'm a little bit confused about using custom shortcuts or actions.

Is it sufficient to store a list of actions in the custom QTabWidget and add them in the constructor like this?

Qt Code:
  1. MyTabWidget::MyTabWidget(QWidget *parent): QTabWidget(parent) {
  2. _actions.append(new QAction(this));
  3. _actions.last()->setShortcut(Qt::Key_F1);
  4. _actions.last()->setShortcutContext(Qt::ApplicationShortcut);
  5. connect(_actions.last(), SIGNAL(triggered()), this, SLOT(doSomething()));
  6. }
  7.  
  8. void MyTabWidget::doSomething() {
  9. ...
  10. }
To copy to clipboard, switch view to plain text mode 

  • Will "doSomething()" be executed if I hit F1 and the tabwidget has no focus?
  • Will a shortcut event be triggered to the tabwidget?
  • Should I use QShortcut instead of QAction?


Bye