Hey!

As guys have already mentioned,event handling is based on virtual functions,meaning that you're free to reimplement them in your derived classes.

I think in the most simple case,what you're trying to achieve might look like that:

*Note that you should reimplement those methods in your rendering widget
Qt Code:
  1. void QMousePressEvent(QMouseEvent* event)
  2. {
  3. // your button-related or other conditions here //
  4.  
  5. beginPos=event->Pos();
  6.  
  7. buttonFlag=true;
  8. }
  9.  
  10. void QMouseReleaseEvent(QMouseEvent* event)
  11. {
  12.  
  13. if(buttonFlag)
  14. {
  15. endPos=event->Pos();
  16.  
  17. shape->draw(beginPos,endPos);
  18.  
  19. }
  20.  
  21.  
  22. }
To copy to clipboard, switch view to plain text mode