1.1.2 Qt信号槽之ConnectionType参数详解

Qt提供了Qt::ConnectionType类型的枚举来控制信号槽连接的类型,根据connect方法中该类型的值来确定连接类型,其主要区别是决定信号触发的时候槽函数是立即执行还是延迟执行。下面详细讲解这几种类型:

Constant Value Description
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 m

你可能感兴趣的:(Qt基础内容教程,qt,connect,信号槽,信号槽连接方式,ConnectionType)