Logo Search packages:      
Sourcecode: qt4-x11 version File versions

int QWidget::grabShortcut ( const QKeySequence key,
Qt::ShortcutContext  context = Qt::WindowShortcut 
) [inherited]

Adds a shortcut to Qt's shortcut system that watches for the given key sequence in the given context. If the context is Qt::ApplicationShortcut, the shortcut applies to the application as a whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut, or to the window itself, Qt::WindowShortcut.

If the same key sequence has been grabbed by several widgets, when the key sequence occurs a QEvent::Shortcut event is sent to all the widgets to which it applies in a non-deterministic order, but with the ``ambiguous'' flag set to true.

You should not normally need to use this function; instead create {QAction}s with the shortcut key sequences you require (if you also want equivalent menu options and toolbar buttons), or create {QShortcut}s if you just need key sequences. Both QAction and QShortcut handle all the event filtering for you, and provide signals which are triggered when the user triggers the key sequence, so are much easier to use than this low-level function.
See also:
releaseShortcut() setShortcutEnabled()

Definition at line 9332 of file qwidget.cpp.

References QKeySequence::isEmpty(), and QWidget::setAttribute().

Referenced by QTabBar::insertTab(), and QTabBar::setTabText().

    if (key.isEmpty())
        return 0;
    return qApp->d_func()->shortcutMap.addShortcut(this, key, context);

Generated by  Doxygen 1.6.0   Back to index