【问题标题】:Qt: how to apply a shortcut( Key_Comma + Key_Return) to actionQt:如何将快捷方式(Key_Comma + Key_Return)应用于操作
【发布时间】:2018-01-25 12:53:52
【问题描述】:

我尝试通过以下代码设置快捷方式,但它不起作用。如果我将其更改为 ALT + Comma 或 ALT + Return,就可以了。但请求是逗号+返回。有谁知道如何在 Qt 上设置这个特殊的快捷方式?

    @shotcut = Qt::Shortcut.new(Qt::KeySequence.new(Qt::Key_Comma + 
    Qt::Key_Return), self, SLOT('save_by_shortcut()'))
    @shotcut.setEnabled(true)

任何帮助将不胜感激!

【问题讨论】:

  • 试试这样:Qt::KeySequence.new(Qt::Key_Comma, Qt::Key_Return)

标签: ruby-on-rails ruby qt qkeysequence


【解决方案1】:

您可以使用QKeySequence 的多参数构造函数来创建它。

像这样:

auto ac = new QAction(this);
ac->setShortcut(Qt::Key_Comma + Qt::Key_Return);

【讨论】:

  • 感谢您的回答,但我只是试了一下,结果就像#<:keysequence:0x0000000c4cc140 ctrl>。我想要实现的只是逗号 + enter which without Ctrl.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多