Qt- “信号-槽”机制之连接类型 部分文档翻译

Qt::ConnectionType


This enum describes the types of connection that can be used between signals and slots. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time.

ConstantValueDescription
Qt::AutoConnection 0 (Default) If the receiver lives in the thread that emits the signal, Qt::DirectConnection is used. Otherwise, Qt::QueuedConnection is used. The connection type is determined when the signal is emitted.
Qt::DirectConnection 1 The slot is invoked immediately when the signal is emitted. The slot is executed in the signalling thread.
Qt::QueuedConnection 2 The slot is invoked when control returns to the event loop of the receiver's thread. The slot is executed in the receiver's thread.
Qt::BlockingQueuedConnection 3 Same as Qt::QueuedConnection, except that the signalling thread blocks until the slot returns. This connection must not be used if the receiver lives in the signalling thread, or else the application will deadlock.
Qt::UniqueConnection 0x80 This is a flag that can be combined with any one of the above connection types, using a bitwise OR. When Qt::UniqueConnection is set, QObject::connect() will fail if the connection already exists (i.e. if the same signal is already connected to the same slot for the same pair of objects). This flag was introduced in Qt 4.6.

Autoconnection:

枚举值:0

描述:该值为默认连接类型。如果“接收器” 在线程中发射信号,那么使用 "DirectConnection"直连型连接,否则则使用队列型连接“QueuedConnection”,连接类型在信号发送时被确定下来。


DirectConnection

枚举值:1

描述:当信号发送后,槽函数立即执行,该槽函数执行在发送信号的线程中。


QueuedConnection:

枚举值:2

描述: 当控制返回到“接收者”的事件循环时,槽函数被执行。该槽函数在“接收者”线程中执行。


BlockingQueuedConnection

枚举值:3

描述: 和队列型连接 “QueuedConnection” 一样, 但不同的是,直到槽函数执行结束返回时,信号发送线程都将处于阻塞状态。 当“接收者”在发送信号的线程中时,不要使用

该连接类型,否则程序将会 “死锁” 。


UniqueConnection

枚举值:0x80

描述: 这个标志位可以通过 “按位 ‘或’” 的方式与上述的信号类型进行混合, 当 “Qt::UniqueConnection” 被设置时, 设置相同的connect()对象将会失败(即改connect已经存在时,不能重复设置)。该标志位在 Qt 4.6 时被引入。




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值