Hello,
there probably are similar questions to the ones I am about to ask somewhere in the depths of the forum (which I have not found yet, at least nothing that will help me).
I have the following Problems with setting shortcuts for QActions:
1. I have a Widget that is built with 2 QLables and 1 QLineEdit. Its suposed to be a numeric indicator so most of the time it should be read only. But i want to be able to enter an editing mode when the user presses "F2" (or any other keysequence...)
So I did the following in my widget:
...
editAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
connect(editAction,SIGNAL(triggered())),this,SLOT(setEditable()));
...
void Display::setEditable()
{
valueDisp->setReadonly(false);
}
...
QAction *editAction= new QAction(this);
editAction->setShortcut(QKeySequence(Qt::Key_F2));
editAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
connect(editAction,SIGNAL(triggered())),this,SLOT(setEditable()));
...
void Display::setEditable()
{
valueDisp->setReadonly(false);
}
To copy to clipboard, switch view to plain text mode
2. I have a MDI subwindow, with a custom texteditor widget in it. Here i have an action that removes the Frame (In order to lock the editor in position)
the action can be called from the mdi system menu, which cant be reached when there is no frame, so i want the Action to have a shortcut eg. "F6".
I have created the Action and given it such a shortcut, but it wont trigger.
I am pretty sure my problems have something to do with the focus when the shortcut is used, but i am not sure how i can correct this.
Can anyone guide me to the answer? 
Thank you for reading
Eric
Bookmarks