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

来源:互联网 发布:主播过度劳累猝死知乎 编辑:程序博客网 时间:2024/05/22 11:37

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.

ConstantValueDescriptionQt::AutoConnection0(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::DirectConnection1The slot is invoked immediately when the signal is emitted. The slot is executed in the signalling thread.Qt::QueuedConnection2The 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::BlockingQueuedConnection3Same 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::UniqueConnection0x80This 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
原创粉丝点击