Has the signal-slot behavior changed?

Detlev Offenbach detlev at die-offenbachs.de
Fri May 26 12:10:02 BST 2023


Am 26.05.23 um 13:06 schrieb Phil Thompson:
> On 25/05/2023 12:32, Detlev Offenbach wrote:
>> Am 25.05.23 um 12:19 schrieb Phil Thompson:
>>> On 25/05/2023 10:59, Detlev Offenbach wrote:
>>>> Hi,
>>>>
>>>> I am observing a strange behavior with the eric-ide code.
>>>>
>>>> Before upgrading to the latest PyQt6 version the following code was 
>>>> OK.
>>>>
>>>>     @pyqtSlot(float)
>>>>     def setZoomFactor(self, zoomFactor):
>>>>         <some code here>
>>>>
>>>> But with latest PyQt6/Qt6 it fails telling me, that the slot signature
>>>> (float) is not compatible. I had to change it like this
>>>>
>>>>     @pyqtSlot(float)
>>>>     @pyqtSlot("qreal")
>>>>     def setZoomFactor(self, zoomFactor):
>>>>         <some code here>
>>>>
>>>> What did I miss in the past?
>>>
>>> What signal are you connecting it to?
>>
>> QPdfView.zoomFactorChanged(qreal zoomFactor)
>>
>> Detlev
>>
>> PS: Similar thing happens with QGraphicsScene.changed(const
>> QList<QRectF> &region). I have to define a slot to be connected to
>> this signal with
>>
>> @pyqtSlot("QList<QRectF>")
>
> Fixed in the next snapshot. I'll release v6.5.1 some time next week.
>
> Personally I don't see much point in using pyqtSlot() unless you want 
> to expose a Python object to other C++ code.

... or you want to ensure the correct argument types. Some signals are 
even emitted multiple times with different signatures and by using 
pyqtSlot() you make sure, the correct signal type was connected.

Detlev

-- 
Detlev Offenbach
detlev at die-offenbachs.de

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0xBD1F26A5DA8A6150.asc
Type: application/pgp-keys
Size: 660 bytes
Desc: OpenPGP public key
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230526/d4dd1bc0/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 236 bytes
Desc: OpenPGP digital signature
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20230526/d4dd1bc0/attachment.sig>


More information about the PyQt mailing list