Debugging Qt's signal-slot connections
What do you do if you think that you've correctly connected a signal to a slot and yet your slot's not being fired?
Here's a bunch of things you can try:
Check the compile log for error messages about undefined signals and slots.
Check the runtime log for errors on connection. If need be, ensure that the connection succeeds by testing its return value (it should return true).
Check to make sure that the
connect
code, the emit code, and the slot code is reached. (Odds are one of them isn't.)Make sure that you declare the connection as follows:
connect(sender, SIGNAL(someSignal(type)), receiver, SLOT(received(type)))
The signal and slot specifications should have the argument types, but not the arguments themselves. Moreover, you can omit
const
and the reference specifications in the arguments; the metaobject compiler strips them anyway.Check the parameters of the signal and slot and ensure that they match precisely.
Check to be sure that you've...