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()) self.shortcut.setContext(Qt.ApplicationShortcut) self.shortcut.activated.connect(self.test)
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?