Qt Code:
  1. class CPT : public ...
  2. {
  3. ...
  4. protected:
  5. bool eventFilter(QObject* o, QEvent* e);
  6. ...
  7. };
  8.  
  9. CPT::CPT(QWidget *parent):QWidget(parent)
  10. {
  11. //various child widgets are added
  12. QTextEdit *te=new QTextEdit(this);
  13. te->installEventFilter(this);
  14. //some other widgets
  15. }
  16.  
  17. bool CPT::eventFilter(QObject* o, QEvent* e)
  18. {
  19. if (e->type() == QEvent::MouseButtonDblClick)
  20. {
  21. // process double click
  22. return true; // eat event
  23. }
  24. // standard event processing
  25. return false;
  26. }
To copy to clipboard, switch view to plain text mode