I am drawing the rectangle on the mouse release event using the following code, please let me know what im doing wrong
{
static int rectCount;
if(!selectionArea().isEmpty())
{
if(rectCount<7)
{
GraphicsRectItem *item = new GraphicsRectItem(selectionArea().boundingRect());
addItem(item);
rectCount ++;
}
}
}
void GraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
static int rectCount;
if(!selectionArea().isEmpty())
{
if(rectCount<7)
{
GraphicsRectItem *item = new GraphicsRectItem(selectionArea().boundingRect());
addItem(item);
rectCount ++;
}
}
QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
To copy to clipboard, switch view to plain text mode
where the GraphicScene and GraphicsRectItem classes are derived from QT QGraphicScene and QGraphicsRectItem as
class GraphicScene : public QGraphicsScene
class GraphicsRectItem : public QGraphicsRectItem
To copy to clipboard, switch view to plain text mode
Bookmarks