[Qt-interest] Simple problem with shortcuts

Castagne Nicolas nicolascastagne at yahoo.fr
Wed Jul 22 14:54:32 CEST 2009


Hi there,

My Document window has a QKeySequence::Copy shortcut, which shortcutContext is set to Qt::WindowShortcut.
This action is placed in the application's menu.

I also need to set a QKeySequence::Copy shortcut on a QAction myAction that belong to a widget of my own called myWidget.
This widget is in a tool window ; it is not a child of the Document window.

The rational would be:
- if myWidget has focus, execute the myWidget's copy action.
- if not, execute the Document window's copy action

Indeed, this is the same as what happens with any QLineEdit copy shortcut.

I've tried many configurations, in particular set myAction's shortcut context to WidgetShortcut.
No success.
The only thing that works is removing the copy action from myWidget...

I have also tried not to use shorcuts in myWidget, but to implement at a low level a keyPressEvent() in myWidget.
Indeed, the widget does NOT receive any key press event when CTRL+C is pressed, even though it has focus.
Uh !

How should I proceed ?


Also, how does Qt's QLineEdit proceeds ? 
Whenever a QLineEdit has focus, and whenever CTRL+C is pressed, the Edit menu flickers even though it does not have any QAction for the considered QLineEdit.... I have tried looking at the code of Qlineedit, but did not see anything there...


Thanks much !
Nicolas



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090722/0cec69d6/attachment.html 


More information about the Qt-interest-old mailing list