我试图让用户能够改变形状的点。如果我创建一个矩形,我可以改变每个点,第二个我添加另一个矩形它只会改变第一个形状的点并将第一个形状移动到新的矩形上。
for (int i = 0; i < ShapePointsOnly.count(); i++) {
int pointShapeX = ShapePointsOnly.at(i).x();
int pointShapeY = ShapePointsOnly.at(i).y();
if (mouseX >= pointShapeX - 10 && mouseX <= pointShapeX + 10) {
if (mouseY >= pointShapeY - 10 && mouseY <= pointShapeY + 10) {
tempValue.setX(pointShapeX);
tempValue.setY(pointShapeY);
selectedPoint = ShapePointsOnly.indexOf(tempValue);
userCanChangePoints = true;
return true;
}
}
}
QBrush noBrush(Qt::NoBrush);
QPen blackPen(Qt::black);
blackPen.setWidth(0);
Rectangle.append(QPointF(300, 300));
Rectangle.append(QPointF(300, 400));
Rectangle.append(QPointF(400, 400));
Rectangle.append(QPointF(400, 300));
RectangleConverted = Rectangle.toPolygon();
scene -> addPolygon(RectangleConverted);
numberOfShapesAdded = numberOfShapesAdded + 1;
addShapesToList();