Qt - emit a signal from a c++ thread -


I want to emit a signal from a C ++ thread (study :: thread) in QT.

How can I do this?

You definitely have a thread ( QThread , std: : Thread or even boost :: threads ). Only you should be cautious with the fifth parameter ( Qt :: ConnectionType ) of your connect function:

If the Qt :: DirectConnection : slot applied immediately Goes (from the current thread), when the signal is emitted. If the Qt :: QueuedConnection : the slot is applied to the control return on the event loop of the receiver thread, the i slot is executed in the receiver thread.

See more options.

The problem is not really that, by which you throw the signal, it is high which thread is being slot activated. For example, I think that QLabel :: settext should be executed with the master thread (primarily the main thread) of QLabel . So if you emit the signal associated with a thread from a QLabel to settext , then with the connection Qt :: AutoConnection , Qt :: QueuedConnection or Qt :: BlockingQuality Connection .


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -