Ya now that error has been cleared, but i could'nt get what attributes should i serialize. below is the code how i create a rect item
This is the function written in my mousePressEvent
{
if (mouseEvent->button() != Qt::LeftButton)
return;
DiagramItem *item;
switch (myMode) {
case InsertItem:
item = new DiagramItem(myItemType);
item->setBrush(myItemColor);
addItem(item);
item->setPos(mouseEvent->scenePos());
emit itemInserted(item);
break;
;
}
}
{
if (mouseEvent->button() != Qt::LeftButton)
return;
DiagramItem *item;
switch (myMode) {
case InsertItem:
item = new DiagramItem(myItemType);
item->setBrush(myItemColor);
addItem(item);
item->setPos(mouseEvent->scenePos());
emit itemInserted(item);
break;
;
}
QGraphicsScene::mousePressEvent(mouseEvent);
}
To copy to clipboard, switch view to plain text mode
This is the code written for creating a polygon item in my DiagramItem's class constructor
myDiagramType = diagramType;
switch (myDiagramType) {
case Step:
}
setPolygon(myPolygon);
}
myDiagramType = diagramType;
QPainterPath path;
switch (myDiagramType) {
case Step:
myPolygon << QPointF(-100, -100) << QPointF(100, -100)
<< QPointF(100, 100) << QPointF(-100, 100)
<< QPointF(-100, -100);
}
setPolygon(myPolygon);
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
}
To copy to clipboard, switch view to plain text mode
I am getting a perfect rect but could'nt cut, copy and paste my QRect Item
Bookmarks