Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Does shortcut context Qt::WidgetShortcut action in menu disable shortcut?
Forum Updated to NodeBB v4.3 + New Features

Does shortcut context Qt::WidgetShortcut action in menu disable shortcut?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 913 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    toralf
    wrote on last edited by
    #1

    Hi.

    I just found myself in a situation similar to the one described in http://stackoverflow.com/questions/1894395/in-qt-how-to-show-keyboard-shortcuts-in-menu-but-disable-them - that is, I wanted to display shortcut info in a menu entry without getting the actual shortcut behaviour, because the shortcut is already handled via a "global" QShortcut. I found a new (possible) solution to the problem, though - I did

    QAction *action=menu->addAction("MyAction");
    QKeySequence shortcut=...;
    
    action->setShortcut(shortcut);
    action->setShortcutContext(Qt::WidgetShortcut);
    

    and found that the action would never be activated by the shortcut (even if disabling the "global" shortcut.)

    Questions:

    • Why exactly is the shortcut (seemingly) inactive in all states when set up this way? It seems like it ought to be when the menu isn't visible, but how about the rather special case when you open the menu, then press the shortcut sequence?
    • Will this work the same way on all systems? Can it be considered as a reliable way to "disable" a menu entry shortcut?

    This solution does seem like bit of a hack in some respects, but less so (I think) than inserting the shortcut text "by hand", and it's a lot easier than messing around with event filters...

    • Toralf
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved