PDA

View Full Version : emit not working in constructor



vinothrajendran
11th December 2014, 10:35
Consider the scenario:
I have 3 CLASS. 1st and 2nd CLASS can be accessed via 3rd CLASS..So i place a connect() inside 3rd CLASS connecting 1st CLASS signal() to 2nd CLASS slot().....But if i place my emit signal in 1st CLASS constructor, its not hitting the slot in 2nd CLASS....But in 1st CLASS, if i place a timer and in its timeout() i emit the signal then appropriate slot is called in 2nd CLASS...

I need to know the reason why emit is not valid inside 1st CLASS constructor....

NOTE: 2nd CLASS object is created before 1st CLASS..So there should not have been a problem with calling emit() from 1st CLASS constructor....

Lesiok
11th December 2014, 10:56
Show the code : crystal ball does not work.
PS.
To connect the signal to the slot you first need to create a sender and receiver objects. Thus, the emission signal in the constructor of the sender does not make any sense.

anbu01
11th December 2014, 11:04
Its simple CLASS1 is not created when signal is emitted.Since you have given in constructor of CLASS1 it will not work.

vinothrajendran
11th December 2014, 11:05
Thank for the reply....I got it now.........

DungeonLords
26th July 2021, 02:23
Consider the scenario:
I have 3 CLASS. 1st and 2nd CLASS can be accessed via 3rd CLASS..So i place a connect() inside 3rd CLASS connecting 1st CLASS signal() to 2nd CLASS slot().....But if i place my emit signal in 1st CLASS constructor, its not hitting the slot in 2nd CLASS....But in 1st CLASS, if i place a timer and in its timeout() i emit the signal then appropriate slot is called in 2nd CLASS...

I need to know the reason why emit is not valid inside 1st CLASS constructor....

NOTE: 2nd CLASS object is created before 1st CLASS..So there should not have been a problem with calling emit() from 1st CLASS constructor....

see example *URL removed by moderator*