Ich kenne keine Möglichkeit, dies über den Designer zu tun, nicht damit vertraut. Sie könnten es mit QShortcut
ziemlich einfach in Code tun.
Hier ist ein Dummy-Widget, das zu veranschaulichen. Drücken Sie Strg + a/Strg + b, um zwischen den Registerkarten zu wechseln.
#include <QtGui>
class W: public QWidget
{
Q_OBJECT
public:
W(QWidget *parent=0): QWidget(parent)
{
// Create a dummy tab widget thing
QTabWidget *tw = new QTabWidget(this);
QLabel *l1 = new QLabel("hello");
QLabel *l2 = new QLabel("world");
tw->addTab(l1, "one");
tw->addTab(l2, "two");
QHBoxLayout *l = new QHBoxLayout;
l->addWidget(tw);
setLayout(l);
// Setup a signal mapper to avoid creating custom slots for each tab
QSignalMapper *m = new QSignalMapper(this);
// Setup the shortcut for the first tab
QShortcut *s1 = new QShortcut(QKeySequence("Ctrl+a"), this);
connect(s1, SIGNAL(activated()), m, SLOT(map()));
m->setMapping(s1, 0);
// Setup the shortcut for the second tab
QShortcut *s2 = new QShortcut(QKeySequence("Ctrl+b"), this);
connect(s2, SIGNAL(activated()), m, SLOT(map()));
m->setMapping(s2, 1);
// Wire the signal mapper to the tab widget index change slot
connect(m, SIGNAL(mapped(int)), tw, SLOT(setCurrentIndex(int)));
}
};
Dies wird als ein Beispiel für Widget-Layout Best Practices nicht dazu gedacht, ... nur eine Möglichkeit, zu veranschaulichen eine Verknüpfung Sequenz zu einer Registerkarte Wechsel zu verdrahten.