Have a look at signals and slots.
http://doc.trolltech.com/4.7/signalsandslots.html