[PyQt] [BUG] QObject::sender() returns the original object that sent the signal
redstone-cold
redstone-cold at 163.com
Sun Apr 5 04:24:45 BST 2015
no matter decorated with @pyqtSlot() or not in PyQt5, this code throw out error
Traceback (most recent call last):
File "test.py", line 39, in on_deleteTasks_triggered
reply.abort()
AttributeError: 'QAction' object has no attribute 'abort'
https://bpaste.net/show/73e54a08957d
在2015年04月04 22时14分, "Yuya Nishihara"<yuya at tcha.org>写道:
On Sat, 4 Apr 2015 21:37:41 +0800 (CST), redstone-cold wrote:
> The PyQt4 version of the same code , self.sender() returns a QNetworkReply,
> the direct object that sent the signal,while in PyQt5,it returns the
> original object that sent the signal.
I see no difference between PyQt4 and PyQt5. Both crashed because self.sender()
is a QAction in on_deleteTasks_triggered(), which is correct.
Traceback (most recent call last):
File "test.py", line 39, in on_deleteTasks_triggered
reply.abort()
AttributeError: 'QAction' object has no attribute 'abort'
> here, on_deleteTasks_triggered() call reply.abort(), thus emitted finished
> signal of reply, then slotFinished() was invoked, so I think the original
> object that sent the signal was QAction, the direct one should be
> QNetworkReply, QObject::sender() should return the DIRECT object that sent
> the signal in this case or else cause so many problems .
What happens if slotFinished() is decorated as @pyqtSlot() ?
> https://bpaste.net/show/9605c5d7e849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150405/f6d12cea/attachment.html>
More information about the PyQt
mailing list