To filter the mouse events in a QTextEdit, do I have to subclass it and implement a custom filter to the class?
I've been trying to add an event filter to a QTextEdit I have placed on the ui, but I can't filter mouse events. I get all other events, but input events(mouse and keyboard).

Qt Code:
  1. moveFilter = new MoveEventFilter(ui->textEdit);
  2. ui->textEdit->setMouseTracking(true);
  3. ui->textEdit->installEventFilter(moveFilter);
To copy to clipboard, switch view to plain text mode 

MoveEventFilter.h:
Qt Code:
  1. #ifndef MOVEEVENTFILTER_H
  2. #define MOVEEVENTFILTER_H
  3. #include <QtGui>
  4. #include <QDebug>
  5.  
  6. class MoveEventFilter : public QObject
  7. {
  8. Q_OBJECT
  9.  
  10. public:
  11. MoveEventFilter(QTextEdit *parent){
  12. //
  13. canMove = false;
  14. }
  15. bool canMove;
  16.  
  17. private:
  18. QPoint dragPosition;
  19.  
  20. protected:
  21. bool eventFilter(QObject *obj, QEvent *event)
  22. {
  23. if (event->type() == QEvent::MouseMove ){
  24. qDebug() << obj->objectName();
  25. }else{
  26. qDebug() << obj->objectName() << event->type();
  27. return QObject::eventFilter(obj, event);
  28. }
  29. }
  30. };
  31.  
  32.  
  33. #endif // MOVEEVENTFILTER_H
To copy to clipboard, switch view to plain text mode