Hi,
Yes that sounds like a solution that would solve my issue, is there any example available online that I could bounce from? I looked through QtTransform library but I can't see a way I could implement it with a mouse event when the user would try to drag for example a triangle shape like this:
QModelIndex index
= ui
->listView
->currentIndex
();
//annotating the shape with a selected name from a text file QString itemText
= index.
data(Qt
::DisplayRole).
toString();
QColor brush_color
(Qt
::green);
//fill color brush_color.setAlpha(50); // alpha index makes brush color more opaque
QPen blackpen
(Qt
::black);
//border color blackpen.setWidth(2); // border width
triangleItem->setBrush(brush_color);
triangleItem->setPen(blackpen);
triangleItem
->setFlag
(QGraphicsItem::ItemIsMovable);
// making the object draggable across graphics view scene->addItem(triangleItem);
QPolygonF Triangle;
Triangle.append(QPointF(-200.,0));
Triangle.append(QPointF(0.,-200));
Triangle.append(QPointF(200.,0));
QModelIndex index = ui->listView->currentIndex(); //annotating the shape with a selected name from a text file
QString itemText = index.data(Qt::DisplayRole).toString();
QGraphicsPolygonItem* triangleItem = new QGraphicsPolygonItem(Triangle);
QColor brush_color(Qt::green); //fill color
brush_color.setAlpha(50); // alpha index makes brush color more opaque
QPen blackpen(Qt::black); //border color
blackpen.setWidth(2); // border width
triangleItem->setBrush(brush_color);
triangleItem->setPen(blackpen);
triangleItem->setFlag(QGraphicsItem::ItemIsMovable); // making the object draggable across graphics view
scene->addItem(triangleItem);
QGraphicsTextItem *RectText = new QGraphicsTextItem(itemText, triangleItem);
To copy to clipboard, switch view to plain text mode
All my polygon items are done in this way, just different shapes.
Thanks for your help.
Bookmarks