简体   繁体   中英

Qt: how to apply a shortcut( Key_Comma + Key_Return) to action

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!

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM