[PyQt] Old vs New Signals

Phil Thompson phil at riverbankcomputing.com
Mon Jul 9 11:18:40 BST 2012


On Sun, 08 Jul 2012 17:43:55 +1000, John Floyd <jfloyd at bigpond.net.au>
wrote:
> Note Corrected Subject (was New vs New ...  sorry)
> 
> I have 2 cases where I am having difficulties in PyQwt signals.  Since
my 
> original post I have investiagted the PyQwt code a bit closer and the 
> following comes from that.  The previous discussions helped me in
looking 
> further into the problem.
> 
> 1) a c++ typedef variable appears to cause problems
> 
> 	The old style signal works
> 	self.picker.connect(picker,SIGNAL('selected(const QwtPolygon &)')
> 			,self.slot)
> 
>    however the new style signal does not work.
> 
> 	self.picker.selected[QwtPolygon].connect(self.slot)
> 
> Reported error
> 	NameError: global name 'QwtPolygon' is not defined
> 
> Yet the MetaObject lists the following as a signal signature
> 	selected(QwtPolygon).
> 
> The reasoning appears to be that in the c++ code QwtPolygon is
typedef'ed
> from 
> QPolygon. Shouldnt this be handled?
> 
> 2) Problems with template argument the signal definition. For example
> 
> 	self.picker.connect(self.picker, 
> 		SIGNAL('selected(const QwtArray<QwtDoublePoint>&)'), self.slot)
> 
> returns an error
> 	TypeError: C++ type 'QwtArray<QwtDoublePoint>' is not supported as a
slot 
> argument type
> 
> The signature is listed in the GmetaObject.
> 
> In the sip code QwtArray<QwtDoublePoint> is MappedTyped as 
> QwtArrayQwtDoublePoint - using this as the signature as below returns
yet 
> another error
> 
> 	self.picker.connect(self.picker, 
> 		SIGNAL('selected(const QwtArrayQwtDoublePoint&)'), self.slot)
> and also as a new signal
> 	self.picker.selected[QwtArrayQwtDoublePoint].connect(self.slot)
> 
> TypeError: connect() failed between selected(QwtArrayQwtDoublePoint) and

> unislot()
> 
> Phil Thompson has said that in this case the python code should accept
the
> c++ 
> signature but it does not.
> 
> Intriquingly the definition of QwtArray is also a c++ typedef in the Qwt
> code.
> 
> The trouble is that for this particlar picker class, the selected signal
> is 
> overloaded multiple times so the signatures are necessary.

As far as I can see the only class with a signal selected(QwtPolygon) is
QwtPicker and that doesn't overload the signal. The only class that does is
QwtPlotPicker, but you don't say which you are using.

Maybe the problem is your picker is a QwtPlotPicker but you are trying to
use QwtPicker.selected? In which case try...

    super(QwtPlotPicker, self.picker).connect(self.slot)

Phil




More information about the PyQt mailing list