Qt: fifth parameter signal (reproduced)

connect signals and slots for connecting the qt, qt indispensable in the programming process. In fact, it has the fifth parameter, but generally use the default value, to meet the special needs may need to manually set the time.

Qt :: AutoConnection: default value, determines the type of signal transmission when using the value of the connection. If the sender and recipient in the same thread, then automatically uses Qt :: DirectConnection type. If the recipient and the sender is not a thread is automatically used Qt :: QueuedConnection type.

Qt :: DirectConnection: slot function will be called when the signal is directly sent to run slot function where the signal sender thread. The effect looks like a direct call function in signal transmission slot position. The more dangerous in a multithreaded environment, it may cause Ben collapse.

Qt :: QueuedConnection: slot function in the event loop control back to the time where the recipient is called a thread, the thread that runs trough the function to signal the receiver. After sending the signal, slot function will not be called immediately, wait until the current function of the recipient executed, after entering the event loop, slot function will be called. Multi-threaded environment generally use this.

Qt :: BlockingQueuedConnection: call the timing of the slot function consistent with the Qt :: QueuedConnection, but after sending a signal sender where the thread is blocked until the tank runs out of function. The sender and recipient must not be in a thread, otherwise the program will deadlock. Occasions between multiple threads need to synchronize may need this.

Qt :: UniqueConnection: This flag bit by pressing or | together in combination with the above four (). When this flag set, and when a signal has been connected to the slot, and then repeat the connection will fail. That is, to avoid duplication connection.

 


Original: https: //blog.csdn.net/life_is_too_hard/article/details/52089723

Guess you like

Origin www.cnblogs.com/1521299249study/p/10950524.html