I think it's well worth while specifying how multiple arguments will work, which may not necessarily be obvious - signal.activated[unicode, int].connect(myfunc) (gives __getitem__ a tuple, no need for extra () around it).
If the target function has been decorated with QtCore.Slot, specifying the signature/s it wants, I also think it would be nice if signal.activated.connect(target) would use that/those rather than raising an error. On Wed, Nov 24, 2010 at 1:25 AM, Matti Airas <[email protected]>wrote: > Hi list, > > as a response to recent discussion on the mailing list, I finally got > around to writing the PSEP draft for defining the behaviour when overloaded > signals are connected. Please see below and comment whether the behaviour is > something you'd like to have or whether the PSEP would need to be changed. > > Cheers, > > ma. > > > > PSEP: 105 > Title: Connecting overloaded signals > Version: $Revision$ > Last-Modified: $Date$ > Author: Matti Airas <[email protected]> > Status: Draft > Type: Standards Track > Content-Type: text/x-rst > Created: 23-Nov-2010 > Post-History: 23-Nov-2010 > > Abstract > ======== > > This PSEP further clarifies PSEP 100 [#psep0100]_ by defining that when > connecting a signal with an overloaded signature, you have to explicitly > define the signature, unless a void signature exists. > > Rationale > ========= > > It is common in Qt for a signal to have several overloaded signatures. > For example, QtGui.QComboBox.activated has alternative ``int`` and > ``unicode`` signatures. > > A specific signature may be defined as shown in the example below:: > > self.cbox.activated[unicode].connect(myfunc) > > In addition to specifying an explict signature, the existing PySide--as > well as PyQt--syntax allows for default signatures to be used by just > omitting the signature when connecting signals:: > > self.cbox.activated.connect(myfunc) > > The default signatures in both PySide and PyQt are defined in > implementation only, and there already exist incompatibilities between > PySide and PyQt in this regard. Since using the default signatures may > lead to obscure errors and undefined behaviour, explicit signatures are > to be preferred. > > Explicit signatures are required > ================================ > > This PSEP defines that if the signal has overloaded signatures, the > explicit signature must be defined when connecting signals to slots. If > the signature is omitted, an exception will be raised. > > Empty signatures are still mapped to default signatures > ------------------------------------------------------- > > As an exception to the rule above, if the signal supplies a void > signature, this is mapped to the default signature. For example, in the > case of ``QPushButton``, both ``clicked()`` and ``clicked(bool)`` are > supported. To connect to the void signature, it is sufficient to use:: > > self.mybutton.clicked.connect(myfunc) > > while the ``bool`` signature still requires the explicit definition: > > self.mybutton.clicked[bool].connect(myfunc) > > > Discussion > ========== > > The issue was first raised in a PySide bug report [#bug327]_. After > that, the issue was discussed on the PySide mailing list [#ml20101021]_. > The general opinion was that explicit signatures are to be preferred. > The first PSEP draft was written using that discussion as the guideline. > > > Compatibility > ============= > > This PSEP introduces a small backwards-incompatible change. Since the > change is minor and only affects behaviour that should be considered > undefined, the implementation will be done before PySide 1.0 release. > > References > ========== > > .. [#psep0100] PSEP 100: New-style Signals and Slots, Airas > (http://www.pyside.org/docs/pseps/psep-0100.html) > > .. [#bug327] PySide Bug 327 > (http://bugs.openbossa.org/show_bug.cgi?id=327) > > .. [#ml20101021] Mailing list discussion: Default signal signature used > in connection, Renato Filho > (http://lists.openbossa.org/pipermail/pyside/2010-October/001206.html) > > Contributors > ============ > > Renato Filho proposed the semantics specified in this PSEP. > > Copyright > ========= > > This document has been placed in the public domain. > > > > .. > Local Variables: > mode: indented-text > indent-tabs-mode: nil > sentence-end-double-space: t > fill-column: 70 > coding: utf-8 > End: > _______________________________________________ > PySide mailing list > [email protected] > http://lists.openbossa.org/listinfo/pyside >
_______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
