1

I tried to set a shortcut by the following code, but it doesn't work. If I change it to ALT + Comma or ALT + Return, it will be fine. but the request is Comma + Return. Does anyone know how to set this special shortcut on Qt?

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

Any help would be appreciated!

trivelt
  • 1,913
  • 3
  • 22
  • 44
Alex Tsai
  • 11
  • 1

1 Answers1

0

You can create it by using the multiple arguments constructor for QKeySequence.

like this:

auto ac = new QAction(this);
ac->setShortcut(Qt::Key_Comma + Qt::Key_Return);
Farhad
  • 4,119
  • 8
  • 43
  • 66
  • Thanks for your answer, but I just try it it turns out to be like #. what I want to achieve is only comma + enter which without Ctrl. – Alex Tsai Aug 17 '17 at 08:44