[Qgis-user] Assigning a keyboard shortcut to a plugin

luca_manganelli at comune.trento.it luca_manganelli at comune.trento.it
Wed Apr 22 06:30:52 PDT 2009


Carson Farmer <carson.farmer at gmail.com> scritti il 22/04/2009 10.55.31

> Hi Luca,

> You can probably do this via the keyPressEvent() of your plugin dialog:

> def keyPressEvent( self, e ):
> if ( e.modifiers() == Qt.ControlModifier or e.modifiers() ==
> Qt.MetaModifier ) and e.key() == Qt.Key_Some_Key:
> # run the tool
> else:
> QDialog.keyPressEvent( self, e )
>
> Hope that helps,

I tried this in the QDialog inherited class:

  def keyPressEvent (self, e):
    if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_C:
        exec()
    else:
        QDialog.keyPressEvent( self, e )

but it seems that this is never called.

Any idea?




More information about the Qgis-user mailing list