I’m trying to bind Qt::META + Qt::Key_Tab shortcut in QTabWidget to switch tabs (like it works in chrome or many other applications).
I have tried every single solution found in google, but this shortcut combination is not working.
I have tried:
- Combinations like
Qt::Key_Control+Qt::Key_Tab,Qt::Key_Meta+Qt::Key_Tab,QKeySequence(Qt::Key_Meta,Qt::Key_Tab),QKeySequence(Qt::META,Qt::Key_Tab) etc. QShortcutQAction- capturing keys using virtual
QWidget::event - capturing keys using virtual
QWidget::eventFilterwithinstallEventFilter - all relative like
keyPressedand etc..
QWidget::event/QWidget::eventFilter catches Shift+Tab, Alt+Tab, but not Ctrl(META)+Tab. When I press Ctrl I see my qDebug output, when I press Ctrl + Tab nothing happens.
Can somebody explain me what is wrong and so special with this particular key combination in QT on OSX?
Doesn't matter what widget, I have created clean GUI project with no other widgets in it - still the same.
Some information:
- OSX Mountain Lion 10.8.5
- QT 5.2
BTW, In Qt Creator I’m not able to set Ctrl+Tab shortcut either, thats really ridiculous.
Note: It works great on Windows, it doesn't work on OSX!
I appreciate any help.
Simple code with QAction:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QAction *pAction = new QAction(this);
QKeySequence keySequence = Qt::META + Qt::Key_Tab; // Not working
// or
QKeySequence keySequence = Qt::ALT + Qt::Key_Tab; // Works Alt+Tab
// or
QKeySequence keySequence = QKeySequence(Qt::Key_Meta, Qt::Key_Tab); // Not working
// or
QKeySequence keySequence = QKeySequence(Qt::META, Qt::Key_Tab); // Not working
pAction->setShortcut(keySequence);
connect(pAction, SIGNAL(triggered()), this, SLOT(shortcut_NextTab()));
addAction(pAction);
}
And slot function:
void MainWindow::shortcut_NextTab()
{
qDebug() << "LOL";
}
Expecting to see LOL in Application output, when pressing Ctrl+Tab.