方法1: 使用诸如按钮控件自带的 setShotCut 方法。在Qt desginer中也通过shotcut属性设置。
// 控件自带的setShotCut方法void setShortcut(const QKeySequence &key);
方法2. 通过信号槽绑定。
MainWindow mainWindow; // 程序的主窗口QShortcut *shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_L), &mainWindow);QObject::connect(shortcut, &QShortcut::activated, [=] {// do bla bla bla});
