Signal Slot Between main and worker thread
-

I have a scenario where object S will emit someThingHappened() signal and Object R have slot HandleOnSomethingHappened().
I know connect should happen with either Auto or Queued Connection.
I have verified Q_OBJECT Macro in both classes, even moc files also got generatedBut My slot is not getting exceuted upon emitting the signal.
Connection have made
a) in Sender class
b) in Reveiver Class In both classes i tried separately- What is the mistake am i doing ?
- what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?
-
@DonCoder said in Signal Slot Between main and worker thread:
What is the mistake am i doing ?
Without code? Does the thread is running it's eventloop?
-
@Christian-Ehrlicher How to check whether QThread is running its event loop or not ?
Also I would like to know
what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?I will post simplified code soon ...
-
@DonCoder said in Signal Slot Between main and worker thread:
How to check whether QThread is running its event loop or not ?
Maybe by reading the documentation of QThread and QThread::run()?
-
@Christian-Ehrlicher How to check whether QThread is running its event loop or not ?
Also I would like to know
what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?I will post simplified code soon ...
@DonCoder said in Signal Slot Between main and worker thread:
what if the Object S is a static object, Can i connect a static object's signal with a non static object slot ?
Don't create static QObjects. This causes problems because static objects are created before main() starts, which conflicts with the requirement that
QCoreApplication(or its subclass) must be the very first QObject to be created.I know connect should happen with either Auto or Queued Connection.
I have verified Q_OBJECT Macro in both classes, even moc files also got generatedYes, these are both correct and good.
From @Christian-Ehrlicher's links, you'll find more requirements. In particular:
- You must not subclass QThread
- You must
start()the QThread