[PyKDE] Signal + Slots Problem

Phil Thompson phil at river-bank.demon.co.uk
Wed Mar 5 21:33:01 GMT 2003


On Wednesday 05 March 2003 8:19 pm, Stuart Bronk wrote:
> Thanks for the suggestion, unfortunately it is now returning a different
> error.
>
> My widget code is now like this:
> 	self.Figure = Figure.Figure() # instantiate Figure
>       self.connect(self.Figure, PYSIGNAL("sigloadQ"), self.loadQ)
>
> Figure class is this:
> 	def loadQ():
>         self.emit(PYSIGNAL("sigloadQ"), ())
>
> The error is:
> 	  File "GLWidget.py", line 27, in __init__
>     		self.connect(self.Figure, PYSIGNAL("sigloadQ"),
> self.loadQ)
> 	  AttributeError: sipThis
>
> sip is the underlying system I believe so I have no idea where this
> comes from.
>
> Any suggestion will be greatly appreciated again, thanks
> Stuart Bronk

Signals can only be emitted by instances that are sub-classes of QObject.

Is Figure?

If it is, have you remembered to call it's super-class ctor?

Phil

> -----Original Message-----
> From: Phil Thompson [mailto:phil at river-bank.demon.co.uk]
> Sent: 05 March 2003 6:26 PM
> To: Stuart Bronk; pykde at mats.gmd.de
> Subject: Re: [PyKDE] Signal + Slots Problem
>
> On Wednesday 05 March 2003 5:28 pm, Stuart Bronk wrote:
> > Hi,
> >
> > I currently trying to set up signals and slots in my application I
> > understand the principals and have read many examples but I am unable
>
> to
>
> > get it working on my own could someone possibly help me out :) as this
> > is only a basic test I am hoping to pass objects later but that is
> > another step :)
> >
> > I have a Widget and a class called Figure I am attempting to connect
>
> the
>
> > method Figure.loadQ with the Widgets loadQ method but I cannot seem to
> > get it to work
> >
> > This is the code I am attempting to use in my widget:
> >
> > def __init__(self,parent,name=None):
> >     	QGLWidget.__init__(self,parent,name)
> > 	self.Figure = Figure.Figure() # instantiate Figure
> >       self.connect(self.Figure, SIGNAL("loadQ()"), self.loadQ())
> >
> > In the Figure class my loadQ method is:
> >
> > def loadQ():
> >       QObject.emit("loadQ()")
> >
> > The interpreter is giving me the following error
> > 	  File "GLWidget.py", line 27, in __init__
> >     	     self.connect(self.Figure, SIGNAL("loadQ()"), self.loadQ())
> > 	  TypeError: Argument 1 of QObject.connect() has an invalid type
> >
> > Any help would be much appreciated :)
>
> SIGNAL() is for Qt signals but you are defining a new Python signal.
>
> Try PYSIGNAL() instead.
>
> Phil




More information about the PyQt mailing list