PDA

View Full Version : emit signal from a slot?



ask8y@yahoo.com
10th June 2010, 21:00
Is it legal to emit a signal in a slot?

I am trying to emit a signal in a slot, and want to trigger another slot. The intended slot does not seems called. Wondering if it's legal to do that?

Thanks,

jnadelman
10th June 2010, 21:07
I have no trouble with it. You may want to be more clear by posting the nw code.

amoswood
10th June 2010, 21:10
I have no problem either. This is legal.

ask8y@yahoo.com
10th June 2010, 23:25
Well, the connect() returned false. signal/slot signatures match.
rc=connect(p, SIGNAL(status(bool)),
this, SLOT(handStatus(bool)));

CeeKey
11th June 2010, 09:13
If it works for you, you can connect the signal with the other signal.

jnadelman
11th June 2010, 13:55
1. What is p?
2. Does p have SIGNAL called status?
3. Use CODE rather than QUOTE around your code.

Well, the connect() returned false. signal/slot signatures match.
rc=connect(p, SIGNAL(status(bool)),
this, SLOT(handStatus(bool)));

ask8y@yahoo.com
11th June 2010, 16:25
Well, the connect() returned false. signal/slot signatures match.
rc=connect(p, SIGNAL(status(bool)),
this, SLOT(handStatus(bool)));

Well, well, well,
It was the typo, handleStatus instead of handStatus. Nice if it failed at compilation time! It works now.

wysota
11th June 2010, 16:31
It can't fail at compilation time because introspection in Qt is done in run-time and not compile-time. Otherwise many of the features Qt offers couldn't be used.

cptG
11th June 2010, 16:34
qt spits out warnings about connections containing non-existant slots/signals to the console when the program is executed, so if you're using QtCreator, look at the application output panel, otherwise execute it from a console.
iirc you need to add CONFIG+=console if you're working on windows for that to work.

cheers,
thomas

tbscope
11th June 2010, 21:18
Is it legal to emit a signal in a slot?

I am trying to emit a signal in a slot, and want to trigger another slot. The intended slot does not seems called. Wondering if it's legal to do that?

Thanks,

I'm just going to state the obvious here:
Keep an eye on infinite loops. Don't emit a signal that eventually calls the slot again. This way you end in an infinite loop.