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?
_actions.
append(new QAction(this));
_actions.last()->setShortcut(Qt::Key_F1);
_actions.last()->setShortcutContext(Qt::ApplicationShortcut);
connect(_actions.last(), SIGNAL(triggered()), this, SLOT(doSomething()));
}
void MyTabWidget::doSomething() {
...
}
MyTabWidget::MyTabWidget(QWidget *parent): QTabWidget(parent) {
_actions.append(new QAction(this));
_actions.last()->setShortcut(Qt::Key_F1);
_actions.last()->setShortcutContext(Qt::ApplicationShortcut);
connect(_actions.last(), SIGNAL(triggered()), this, SLOT(doSomething()));
}
void MyTabWidget::doSomething() {
...
}
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
Bookmarks