Enable mouse tracking on the viewport and catch mouse move events either by subclassing and reimplementing the event handler or alternatively with an event filter. The latter approach does not require subclassing.