[PyQt] QObject::​sender() returns the original object that sent the signal

redstone-cold redstone-cold at 163.com
Mon Apr 6 08:35:08 BST 2015


test code
https://bpaste.net/show/79b893f0d9fd


The PyQt4 version of the same code , self.sender() in downloadProgress,no matter decorated with @pyqtSlot(int, int) or not, returns a QNetworkReply ,the direct object that sent the signal, when on_deleteTasks_triggered(),


while in PyQt5,it  returns the original object that sent the signal,thus throw out error 


Traceback (most recent call last):
  File "E:\network.py", line 67, in downloadProgress
    print(reply, reply.error())
AttributeError: 'QAction' object has no attribute 'error'




QObject::sender() should return the DIRECT object that sent the signal in this case or else cause so many problems .












在2015年04月05 23时56分, "Detlev Offenbach"<detlev at die-offenbachs.de>写道:

Some people have reported the very same issue for eric as well. However, it doesn’t seem to be reproducible (maybe a memory corruption issue).

Detlev

> Am 05.04.2015 um 13:10 schrieb Yuya Nishihara <yuya at tcha.org>:
>
> On Sun, 5 Apr 2015 11:17:18 +0800 (CST), redstone-cold wrote:
>> sorry ,I posted the wrong code last time, this is the right code
>> https://bpaste.net/show/a8a5c72f9c0c
>> for slotFinished() if decorated with @pyqtSlot() in PyQt5 seems works fine ,
>> but if not ,
>>
>> Traceback (most recent call last):
>>  File "E:\network.py", line 57, in slotFinished
>>    print(reply, reply.error())
>> AttributeError: 'QAction' object has no attribute 'error'
>>
>> PyQt4 doesn't care if  slotFinished() decorated with @pyqtSlot() or not ,
>> while PyQt5 does ,anyone can explain why ?
>
> Perhaps, reply.abort() doesn't emit finished() immediately (i.e. in the same
> call stack) on your Qt4 environment. My PyQt4 has the same issue.
>
>  Debian Linux sid
>  libqt4-core 4:4.8.6+git64-g5dc8b2b+dfsg-3
>  python-qt4 4.11.2+dfsg-1
>
> Regards,
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Detlev Offenbach
detlev at die-offenbachs.de



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150406/ec9774e5/attachment-0001.html>


More information about the PyQt mailing list