[Qgis-developer] Problem in Connecting three different signals to the same event handler

Bishwarup Banerjee bishwarup.banerjee at gmail.com
Thu Apr 8 10:22:25 EDT 2010


Dear All,

I am struck with a problem while handling Signal and slot through pyqt

The problem is as follows:

I have three different menu items, each connected to the same event.
In side my event handling function , I want to find out which menu item was
clicked.

I tried self.sender().objectName(),

But I get the following error: ("TF is my class name")

*AttributeError: TF instance has no attribute 'sender'*

When I tried to inherit the QObject class in my class, the above error is
gone, but instead of getting the message "inside" it is not showing
anything. (Neither the error message nor the "inside" message).

The code is as follows:

QtCore.QObject.connect( self.Pch, QtCore.SIGNAL("triggered()"),
self.CR_Clicked )
QtCore.QObject.connect( self.TFe, QtCore.SIGNAL("triggered()"),
self.CR_Clicked )
QtCore.QObject.connect( self.IE, QtCore.SIGNAL("triggered()"),
self.CR_Clicked )

def CR_Clicked(self):
        eventName = self.sender().objectName()

        infoString = QString("inside")
        QMessageBox.information(self.iface.getMainWindow(),"SF",infoString)


It will be very kind of you if you can let me know as of where I am going
wrong, or direct me to any link.


With Warm Regards,
Bishwarup
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20100408/87d47e24/attachment.html


More information about the Qgis-developer mailing list