在閱讀代碼時遇到了有五個參數的connect語句,因而去查找QT Assistant,發現其實他原本就是五個參數,只是平時第五個參數採用缺省參數而不顯示。
第五個參數列表:
enum Qt::ConnectionType
app
Constant | Description |
---|---|
Qt::AutoConnection | (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 | The slot is invoked immediately when the signal is emitted. The slot is executed in the signalling thread. |
Qt::QueuedConnection | 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 | 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 | 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. |
機翻:oop
常數
價值
描述
Qt: AutoConnection
0
(默認)若是接收器位於發出信號的線程中,則使用Qt::DirectConnection。不然,使用Qt::QueuedConnection。鏈接類型是在信號發出時肯定的。
Qt: DirectConnection
1
當信號發出時,當即調用插槽。槽在信號線程中執行。
Qt: QueuedConnection
2
當控制返回到接收方線程的事件循環時,將調用該槽。插槽在接收方的線程中執行。
Qt: BlockingQueuedConnection
3.
與Qt::QueuedConnection相同,除了信號線程阻塞直到槽返回。若是接收方處於發送信號的線程中,則不能使用此鏈接,不然應用程序將死鎖。
Qt: UniqueConnection
0 x80
這是一個能夠使用按位或與上述任何一種鏈接類型組合的標誌。當Qt::UniqueConnection被設置時,若是鏈接已經存在,QObject::connect()將會失敗(也就是說,若是相同的信號已經鏈接到相同的槽上,對應於相同的對對象)。在Qt 4.6中引入了這個標誌。
線程