<div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;">sorry ,I posted the wrong code last time, this is the right code </div><div>https://bpaste.net/show/a8a5c72f9c0c</div><div><pre style="color: rgb(0, 0, 0); font-family: 'Microsoft Yahei', 微软雅黑, verdana; font-size: 16px; word-break: break-word; font-stretch: normal; line-height: 24px; padding: 8px 10px; margin-top: 0px; margin-bottom: 0px;">for <span style="line-height: 23.7999992370605px; font-family: arial; font-size: 14px;">slotFinished() if </span>decorated with @pyqtSlot() in PyQt5 seems works fine ,but if not ,</pre><pre style="color: rgb(0, 0, 0); font-family: 'Microsoft Yahei', 微软雅黑, verdana; font-size: 16px; word-break: break-word; font-stretch: normal; line-height: 24px; padding: 8px 10px; margin-top: 0px; margin-bottom: 0px;"><br></pre><pre style="word-break: break-word; font-stretch: normal; padding: 8px 10px; margin-top: 0px; margin-bottom: 0px;"><font face="Microsoft Yahei, 微软雅黑, verdana" size="3"><span style="line-height: 24px;">Traceback (most recent call last):
File "E:\network.py", line 57, in slotFinished
print(reply, reply.error())
AttributeError: 'QAction' object has no attribute 'error'</span></font></pre><pre style="word-break: break-word; font-stretch: normal; padding: 8px 10px; margin-top: 0px; margin-bottom: 0px;"><font face="Microsoft Yahei, 微软雅黑, verdana" size="3"><span style="line-height: 24px;"><br></span></font></pre><pre style="word-break: break-word; font-stretch: normal; padding: 8px 10px; margin-top: 0px; margin-bottom: 0px;"><font face="Microsoft Yahei, 微软雅黑, verdana" size="3"><span style="line-height: 24px;">PyQt4 doesn't care if </span></font><span style="font-family: 'Microsoft Yahei', 微软雅黑, verdana; font-size: 16px; line-height: 24px;"> </span><span style="line-height: 23.7999992370605px;">slotFinished() </span><span style="line-height: 23.7999992370605px;"> </span><span style="font-family: 'Microsoft Yahei', 微软雅黑, verdana; font-size: 16px; line-height: 24px;">decorated with @pyqtSlot() or not , while PyQt5 does ,anyone can explain why ?</span></pre><pre style="color: rgb(0, 0, 0); font-family: 'Microsoft Yahei', 微软雅黑, verdana; font-size: 16px; word-break: break-word; font-stretch: normal; line-height: 24px; padding: 8px 10px; margin-top: 0px; margin-bottom: 0px;"><br></pre></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div></div><!-- jy5ContentSuffix --><div>在2015年04月04 22时14分, "Yuya Nishihara"<yuya@tcha.org>写道:</div><blockquote id="isReplyContent" style="padding-left:1ex; margin: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>On Sat, 4 Apr 2015 21:37:41 +0800 (CST), redstone-cold wrote:<br>> The PyQt4 version of the same code , self.sender() returns a QNetworkReply,<br>> the direct object that sent the signal,while in PyQt5,it returns the<br>> original object that sent the signal.<br><br>I see no difference between PyQt4 and PyQt5. Both crashed because self.sender()<br>is a QAction in on_deleteTasks_triggered(), which is correct.<br><br> Traceback (most recent call last):<br> File "test.py", line 39, in on_deleteTasks_triggered<br> reply.abort()<br> AttributeError: 'QAction' object has no attribute 'abort'<br><br>> here, on_deleteTasks_triggered() call reply.abort(), thus emitted finished<br>> signal of reply, then slotFinished() was invoked, so I think the original<br>> object that sent the signal was QAction, the direct one should be<br>> QNetworkReply, QObject::sender() should return the DIRECT object that sent<br>> the signal in this case or else cause so many problems .<br><br>What happens if slotFinished() is decorated as @pyqtSlot() ?<br><br>> https://bpaste.net/show/9605c5d7e849<br></blockquote><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>