Something like this

Qt Code:
  1. void RubberBand::onPasteBtn(){
  2. qApp->installEventFilter( this );
  3. qApp->enter_loop();
  4. }
  5. void RubberBand::mousePressEvent(QMouseEvent *event)
  6. {
  7. //other stuffs
  8. }
  9. void RubberBand::mouseMoveEvent(QMouseEvent *event)
  10. {
  11. //other stuffs
  12. }
  13. void RubberBand::mouseReleaseEvent(QMouseEvent *event)
  14. {
  15. //other stuffs
  16. }
  17. bool RubberBand::eventFilter( QObject *obj, QEvent *e ){
  18.  
  19. if( (e->type() == QEvent::Paint) || (e->type() == QEvent::Resize) ||
  20. (e->type() == QEvent::FocusIn) || (e->type() == QEvent::FocusOut) )
  21. {
  22. return FALSE;
  23. }
  24. if ( e->type() == QEvent::KeyPress && ((QKeyEvent *)e)->key() == Qt::Key_Escape ){
  25. // remove this event filter and exit the current event loop
  26. qApp->removeEventFilter( this );
  27. qApp->exit_loop();
  28. delete m_Rubberband;
  29. m_Rubberband = 0;
  30. return TRUE;
  31. }
  32. if( e->type() == QEvent::MouseMove ){
  33. m_pasteRect.setTop( ((QMouseEvent *)e)->pos().x() );
  34. m_pasteRect.setLeft( ((QMouseEvent *)e)->pos().y() );
  35.  
  36. m_pasteRect.setBottom( ((QMouseEvent *)e)->pos().x() + 50 );
  37. m_pasteRect.setRight( ((QMouseEvent *)e)->pos().y() + 50 );
  38.  
  39. if( !m_Rubberband )
  40. m_Rubberband = new QRubberBand(QRubberBand::Rectangle, this);
  41.  
  42. m_Rubberband->setGeometry( m_pasteRect );
  43. m_Rubberband->show();
  44.  
  45. return TRUE;
  46. }
  47. else if( e->type() == QEvent::MouseButtonRelease ){
  48. // remove this event filter and exit the current event loop
  49. qApp->removeEventFilter( this );
  50. qApp->exit_loop();
  51. delete m_Rubberband;
  52. m_Rubberband = 0;
  53. return TRUE; // eat event
  54. }
  55. return TRUE; // block standard event processing
  56. }
To copy to clipboard, switch view to plain text mode 

Now in the above code there are both events and eventFilter. So do you still I'm doing something wrong above. Please bear with me. I want to clear my fundas...
Thanks