[PyQt] Fw:Re: Re: [BUG] QObject::sender() returns the original object that sent the signal
redstone-cold
redstone-cold at 163.com
Thu Apr 9 05:41:31 BST 2015
----- 转发邮件信息 -----
发件人: "Alan Ezust"<alan.ezust at gmail.com>
发送时间: 2015年04月09 星期四 02:34
收件人: "redstone-cold"<redstone-cold at 163.com>
主题: Re: Re: [PyQt] [BUG] QObject::sender() returns the original object that sent the signal
My guess is that the "direct connection" connection types sometimes get optimized into a direct python call, if the signal and slot are both python, and sometimes they bypass the regular Qt signal-slot mechanism, which is what is responsible for setting the QObject sender() properly before invoking the slot.
So by changing the connection type to QueuedConnection, this forces the connection to go through Qt's signal-slot mechanism which does set the sender() correctly.
This is only my guess.
On Tue, Apr 7, 2015 at 5:25 AM, redstone-cold <redstone-cold at 163.com> wrote:
Yes, that's worked, but seems not clean and neat.
在2015年04月07 12时32分, "Alan Ezust"<alan.ezust at gmail.com>写道:
What happens if you change the connection type to Qt.QueuedConnection? Does that help?
I think the direct connection is what is causing the problem.
On Sat, Apr 4, 2015 at 8:24 PM, redstone-cold <redstone-cold at 163.com> wrote:
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
_______________________________________________
PyQt mailing list PyQt at riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150409/cacbae96/attachment.html>
More information about the PyQt
mailing list