Re: [PyQt] Connecting to base class signals in subclass

2010-03-20 Thread Russell Valentine
On 03/19/10 18:45, Demetrius Cassidy wrote:
 
 I am not sure if this is the intended behavior, but if I subclass a QWidget
 instance, and then try to connect to one of those signals in my subclass, I
 get a TypeError:
 
 class MyLabel(QtGui.QLabel):
 ... def __init__(self):
 ... self.linkActivated.connect(self._lnkActivated)
 ...
 ... def _lnkActivated(self, link):
 ... pass
 ...
 l = MyLabel()
 Traceback (most recent call last):
   File stdin, line 1, in module
   File stdin, line 3, in __init__
 TypeError: pyqtSignal must be bound to a QObject, not 'MyLabel'

 
 Why can't I connect to my base class's signals in my subclass? 



You need to call the parent's init.
super(QtGui.QLabel, self).__init__()

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Connecting to base class signals in subclass

2010-03-19 Thread Demetrius Cassidy

I am not sure if this is the intended behavior, but if I subclass a QWidget
instance, and then try to connect to one of those signals in my subclass, I
get a TypeError:

 class MyLabel(QtGui.QLabel):
... def __init__(self):
... self.linkActivated.connect(self._lnkActivated)
...
... def _lnkActivated(self, link):
... pass
...
 l = MyLabel()
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 3, in __init__
TypeError: pyqtSignal must be bound to a QObject, not 'MyLabel'


Why can't I connect to my base class's signals in my subclass? 
-- 
View this message in context: 
http://old.nabble.com/Connecting-to-base-class-signals-in-subclass-tp27951038p27951038.html
Sent from the PyQt mailing list archive at Nabble.com.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt