一个动作的两个快捷方式 [英] Two shortcuts for one action

查看:35
本文介绍了一个动作的两个快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为一项操作使用两个快捷方式.

I need two shortcuts for one action.

Ctrl+1 or ctrl+s

有没有办法做到这一点?或者我必须创建操作的副本,然后为此操作分配第二个快捷方式?

Is there any way how to do that? Or I have to create copy of the action and than assign second shortcut to this action?

推荐答案

为了在一个动作上安装多个快捷方式,你可以使用 QAction::setShortcuts(const QList &shortcuts)功能.例如:

In order of install multiple shortcuts on an action you can use QAction::setShortcuts(const QList<QKeySequence> & shortcuts) function. For example:

QList<QKeySequence> shortcuts;
shortcuts << QKeySequence("Ctrl+1") << QKeySequence("Ctrl+S");
action->setShortcuts(shortcuts);

这篇关于一个动作的两个快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆