how to emit a signal from a non_GUI class and from a non-GUI thread which we can detect in main GUI class

StackOverflow https://stackoverflow.com/questions/23515516

  •  17-07-2023
  •  | 
  •  

Question

I want to Show an Image from other class into QLabel but to inform the GUI that a new Frame is available. I need to emit a Signal from a non_GUI class and from a non-GUI thread.

Is there any way to do it ?

Was it helpful?

Solution

A signal can be emitted from any class object which inherits QObject. And that signal can be caught in any slot provided the signatures are compatible. You can just inherit QObject by your non-GUI class. Then connect the signal-slot for a specific object. But since multi-threading is involved, you should be careful about any shared data access. Also know properly about connection types and thread affinity

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top