much nicer implementation of qt4reactor (h/t) kmike