c++ - Qt: MouseMove not functioning -


in qt application, need track mouse movement. that, created eventfilter , installed correctly this:

bool iarmmainwindow::eventfilter(qobject *obj, qevent *event) {     if (event->type() == qevent::mousemove)//not working     {         iarm->printstatus("hi"); //this debugging      }     if (event->type() == qevent::mousebuttonpress){                 //here staff working correctly         } //other staff } 

the problem event type mousemove not work.

any idea?

you should qt, want mouse move events via setmousetracking() function. take attention, should call before installing filter (say in c-tor of widget's subclass). i'll recommend little bit easier way instead of installing event filter: overwrite qwidget::mousemoveevent() in widget's subclass. this:

// header: class mywidget {     ...     void mousemoveevent( qmouseevent * event ); };  // source: mywidget::mywidget() {     setmousetracking(); }  void mywidget::mousemoveevent( qmouseevent * event ) {     // want } 

Comments