Originally Posted by
Gopala Krishna
I just made a note of them from source of QTextControl. Probably i need to add all action that interferes in a list and enable/disable them appropriately. But what if these shortcuts vary with qt versions - ? I mean if the next version adds/removes a shortcut.
For now I had to stick on to this solution. I worte the followingg code based on suggestion of jpn.
void QucsMainWindow::setInterferingActionsDisabled(bool state)
{
foreach
(QAction *action, interferingActions
) { action->setDisabled(state);
#if QT_VERSION < 0x040300
Qt::ShortcutContext c = state ? Qt::WidgetShortcut : Qt::WindowShortcut;
action->setShortcutContext(c);
#endif
}
}
void QucsMainWindow::setInterferingActionsDisabled(bool state)
{
foreach(QAction *action, interferingActions) {
action->setDisabled(state);
#if QT_VERSION < 0x040300
Qt::ShortcutContext c = state ? Qt::WidgetShortcut : Qt::WindowShortcut;
action->setShortcutContext(c);
#endif
}
}
To copy to clipboard, switch view to plain text mode
Yup you do need that preprocessor directive since qt-4.2.* has a bug where the action, though disabled, responds to the shortcuts associated. But it seems to be fixed in qt4.3
BTW, is modifying shortcut context a heavy operation since i may be ececuting this slot quite often ?
I still will be happy to modify my code if someone can help me with more cleaner hack
Bookmarks