[PyQt] [BUG] QObject::sender() returns the original object that sent the signal
Yuya Nishihara
yuya at tcha.org
Sat Apr 4 15:14:03 BST 2015
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
More information about the PyQt
mailing list