[PyQt] New vs new signals - signatures

Phil Thompson phil at riverbankcomputing.com
Fri Jun 29 13:42:15 BST 2012


On Fri, 29 Jun 2012 21:51:34 +1000, John Floyd <jfloyd at bigpond.net.au>
wrote:
> On Fri, 29 Jun 2012 10:00:44 you wrote:
>> On Fri, 29 Jun 2012 18:02:47 +1000, John Floyd <jfloyd at bigpond.net.au>
>> 
>> wrote:
>> > On Fri, 29 Jun 2012 08:52:00 you wrote:
>> >> On Fri, 29 Jun 2012 17:22:51 +1000, John Floyd
<jfloyd at bigpond.net.au>
>> >> 
>> >> wrote:
>> >> > The question relates to the signatures used to connect overloaded
>> >> 
>> >> signals.
>> >> 
>> >> > What do you use for signature in the new signals.  I have tried
>> >> > using
>> >> 
>> >> the
>> >> 
>> >> > same
>> >> > arguments that are specified in the old method but does not work.
>> >> > 
>> >> > Eg an example from pyqwt
>> >> > 
>> >> > old method
>> >> > 
>> >> > 	self.picker.connect(self.picker, SIGNAL('selected(const
>> >> > 	QwtPolygon&)'),
>> >> > 
>> >> >       self.slotter)
>> > 
>> > This works
>> > 
>> >> > have tried
>> >> > 
>> >> > 	self.picker.selected[QwtPolygon].connect(self.slotter)
>> >> > 
>> >> > and
>> >> > 
>> >> > 	self.picker.selected['QwtPolygon'].connect(self.slotter)
>> >> > 
>> >> > with no success.
>> >> 
>> >> Define "no success".
>> > 
>> > The 2nd call results in "KeyError: 'there is no matching overloaded
>> > signal'"
>> 
>> What does the first call result in?
> Actually QwtPolygon does not appear to be defined at the python level.

So it's never going to work. You need to find out how PyQwt implements
QwtPolygon.

> The reason I tried it was that a listing of signals (a short script that

> scanned the gmetaobject) indicated that this was the valid variable type
> and 
> that the old style works.  As a string index is acceptable - what string
> can 
> be used in the new style?  Obviously there is not a one to one
> relationship 
> between signatures in old and new methods. How can we determine those
that
> are 
> recognized for the new style.
> 
> I have also tried (based on the arguments to old style connect
> self.picker.selected['selected(const QPolygon)'].connect(self.slotter)
> self.picker.selected['QPolygon'].connect(self.slotter)
> 
> with resulting error: TypeError: C++ type ..... is not supported as a
> bound 
> signal type argument type
>> 
>> >> > the user docs does suggest "A type is either a Python type object
or
>> 
>> a
>> 
>> >> > string
>> >> > that is the name of a C++ type"
>> >> > 
>> >> > In this regard I have notices that in the code generated from the
>> >> > sip
>> >> > files,
>> >> > the pyqt4QtSignal defintion is
>> >> > 
>> >> > 	selected(QwtPolygon)
>> >> > 
>> >> > This is particularly confusing where for mappedtypes from a
template
>> >> 
>> >> where
>> >> 
>> >> > the
>> >> > c++ variable is QArray<QwtDoublePoint> which is in the c++
signature
>> >> > whilst
>> >> > the python 'equivalent' is QwtQArrayQwtDoublePoint.
>> >> > 
>> >> > Clarification would be very useful.  At the moment I am not sure
if
>> >> 
>> >> there
>> >> 
>> >> > is a
>> >> > coding problem (mine or at the sip end) or just my ignorance.
>> >> 
>> >> They should be interchangeable. In the current of PyQt a bound
signal
>> 
>> has
>> 
>> >> a "signal" attribute that is the corresponding C++ signal so you can
>> >> check
>> >> what signature is actually being used.
>> > 
>> > Not sure exactly what you mean here, I have tried the following
>> > 
>> > print self.picker.selected.signal
>> > 
>> > and get "'PyQt4.QtCore.pyqtBoundSignal' object has no attribute
>> 
>> 'signal'"
>> 
>> What version of PyQt? Like I said, this is available in the current
>> version.
> 
> OK I am running PyQt4 4.8.6 not the very latest.
> Is there another way to obtain the signatures that the python signal
> methods 
> recognizes?

You can look at the PyQwt source code.

Phil


More information about the PyQt mailing list