python – 暂时抑制PyQt事件?

我正在填充QTreeWidget的一个分支,然后将分支的父节点上的展开属性设置为true. itemExpanded信号响应时触发,这不是我想要的.在一段代码中是否存在抑制或吸收信号的临时方法?

解决方法:

您可以使用QObject :: blockSignals设置信号阻塞.
http://doc.qt.nokia.com/stable/qobject.html#blockSignals

bool QObject::blockSignals ( bool block )
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). If block is false, no such blocking will occur.
The return value is the previous value of signalsBlocked().
Note that the destroyed() signal will be emitted even if the signals for this object have been blocked.
See also signalsBlocked().

上一篇:QT-QTreeWidget添加右键菜单响应时间的笔记


下一篇:python – PyQT QTreeWidget迭代