暂时抑制 PyQt 事件? [英] Suppress PyQt event temporarily?

查看:52
本文介绍了暂时抑制 PyQt 事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm populating a branch of a QTreeWidget and then setting the expanded attribute on the parent of the branch to true. The itemExpanded signal fires in response, which is not what I want. Is there a temporary way to suppress or absorb signals during a segment of code?

推荐答案

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

You can set blocking of signals using QObject::blockSignals.
http://doc.qt.nokia.com/stable/qobject.html#blockSignals

bool QObject::blockSignals ( bool block )
如果 block 为真,则此对象发出的信号将被阻止(即,发出信号不会调用与其连接的任何东西).如果 block 为 false,则不会发生此类阻塞.返回值是signalsBlocked() 的前一个值.请注意,即使此对象的信号已被阻止,也会发出 destroy() 信号.另见signalsBlocked().

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().

这篇关于暂时抑制 PyQt 事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆