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
{
// your button-related or other conditions here //
beginPos=event->Pos();
buttonFlag=true;
}
{
if(buttonFlag)
{
endPos=event->Pos();
shape->draw(beginPos,endPos);
}
}
void QMousePressEvent(QMouseEvent* event)
{
// your button-related or other conditions here //
beginPos=event->Pos();
buttonFlag=true;
}
void QMouseReleaseEvent(QMouseEvent* event)
{
if(buttonFlag)
{
endPos=event->Pos();
shape->draw(beginPos,endPos);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks