在閱讀代碼時遇到了有五個引數的connect陳述句,于是去查找QT Assistant,發現其實他本來就是五個引數,只是平時第五個引數采用預設引數而不顯示,
第五個引數串列:
enum Qt::ConnectionType
| 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. |
機翻:
常數
價值
描述
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中引入了這個標志,
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/174873.html
標籤:其他
