[Qgis-user] Check if a selectionChanged signal is connected to any slot?

Tudorache, Marian Marian.Tudorache at navcanada.ca
Mon Oct 2 08:30:19 PDT 2017


Hi everyone,

I have connected the signal selectionChanged so some code, which is executed after features are selected.

myLayer.selectionChanged.connect(self.executeAfterSelection)

Then I have a method self. executeAfterSelection(self, featuresIds)

The SIGNAl/SLOT tandem works but now I realized every time when I call myLayer.selectionChanged.connect(self.executeAfterSelection)  It does not overwrite my previous call. It creates a second signa/slot tandem. During running the method  executeAfterSelection is excuted twice, three times etc.

How can I check if the SIGNAL selectionChanged is connected to the slot executeAfterSelection before I run myLayer.selectionChanged.connect(self.executeAfterSelection)?

I tried this:
receiversCount = QtCore.QObject.receivers(QtCore.SIGNAL("selectionChanged()")
receiversCount = QtCore.QObject.receivers(QtCore.SIGNAL("selectionChanged")
receiversCount = QtCore.QObject.receivers(QtCore.SIGNAL("myLayer.selectionChanged()")
receiversCount = QtCore.QObject.receivers(QtCore.SIGNAL("myLayer.selectionChanged")

Every time I get this error:

QObject.receivers(SIGNAL()): first argument of unbound method must have type 'QObject').


Thanks,
Marian




________________________________

This electronic message, as well as any transmitted files included in the electronic message, may contain privileged or confidential information and is intended solely for the use of the individual(s) or entity to which it is addressed. If you have received this electronic message in error please notify the sender immediately and delete the electronic message. Any unauthorized copying, disclosure or distribution of the electronic message is strictly forbidden. NAV CANADA accepts no liability for any damage caused by any virus and/or other malicious code transmitted by this electronic communication.

Le pr?sent message ?lectronique et tout fichier qui peut y ?tre joint peuvent contenir des renseignements privil?gi?s ou confidentiels destin?s ? l'usage exclusif des personnes ou des organismes ? qui ils s'adressent. Si vous avez re?u ce message ?lectronique par erreur, veuillez en informer l'exp?diteur imm?diatement et supprimez le. Toute reproduction, divulgation ou distribution du pr?sent message ?lectronique est strictement interdite. NAV CANADA n'assume aucune responsabilit? en cas de dommage caus? par tout virus ou autre programme malveillant transmis par ce message ?lectronique.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20171002/9f9804b0/attachment.html>


More information about the Qgis-user mailing list