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
  •  | 
  •  

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 ?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top