0

ユーザーが形状のポイントを変更できるようにしようとしています。1 つの Rectangle を作成すると、各ポイントを変更できますが、2 番目に別の Rectangle を追加すると、最初の形状のポイントのみが変更され、最初の形状が新しい Rectangle の上に移動します。

    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();
4

0 に答える 0