I'm writing a plugin using QGIS. I want to associate a shortcut to a procedure called "test".

The code i am using is the following :

self.shortcut = QShortcut(QKeySequence(Qt.Key_Q), self.iface.mainWindow())

For unknown reasons it seems to work erratically:

When I define a new key sequence (let's say "A") it is ok. I change the code, reload the plugin (with plugin reloader tool) the shortcut is working. Then the shortcut seems to get unresponsive (I don't find the reason why..)

I choose another key sequence (let's say "Z"), it is working.

When I try to switch it back to a previous setting (back to "A" for example) it is not working either ...

It seems that only new key sequence choices are working (for a while only ...)

What could I be doing wrong?

Is it an issue that could occur only during design mode of the plug-in?

  • Or maybe is it just something like a scope issue ? ... – snaileater Apr 23 '18 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.