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. ...
Get Application Development with Qt Creator - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.