[PyQt] Keyboard shortcuts not working

Karlo Lozovina karlo.lozovina at gmail.com
Fri Apr 11 09:53:20 BST 2008


On 4/11/08, Ulrich Berning <ulrich.berning at denviso.de> wrote:

>  From the docs:
>  "Actions are added to widgets using QWidget::addAction(). Note that an
> action must be added to a widget before it can be used; this is also true
> when the shortcut should be global (i.e., Qt::ApplicationShortcut as
> Qt::ShortcutContext)."

>  Add the line
>   self.addAction(self.action)
>  and it works.

Thanks (both Ulrich and Mark), that's it!
I re-read that part of the docs at least twice, and still didn't
notice that :(. And the book I'm using adds the action to a
toolbar/menubar, no mention of what to do when the application has
neither.

Btw, is there any difference using QAction over QShortcut, for
applications that don't have toolbar/menubar?

-- 
Mosor


More information about the PyQt mailing list