Hello, everyone.
So, I have a class called TwoDotsGraphicsScene which subclasses QGraphicsScene. In some place I add a QGraphicsGroup to it, where one of the items is QGraphicsLineItem:
//some code....
QLineF perpendicLine
(QLineF(firstPoint
->scenePos
(), point
).
normalVector().
unitVector());
perpendicLine.setLength(200);
QPointF centerPoint
= perpendicLine.
pointAt(0.5);
perpendicLine.translate(-centerPoint.x(), -centerPoint.y());
perpLine
->setPen
(QPen(Qt
::red));
secondPointGroup->addToGroup(perpLine);
this->addItem(secondPoint);
//some code....
//some code....
secondPoint = new QGraphicsItemGroup(0);
QLineF perpendicLine(QLineF(firstPoint->scenePos(), point).normalVector().unitVector());
perpendicLine.setLength(200);
QPointF centerPoint = perpendicLine.pointAt(0.5);
perpendicLine.translate(-centerPoint.x(), -centerPoint.y());
perpLine = new QGraphicsLineItem(perpendicLine);
perpLine->setPen(QPen(Qt::red));
secondPointGroup->addToGroup(perpLine);
this->addItem(secondPoint);
//some code....
To copy to clipboard, switch view to plain text mode
perpLine - is a class public variable.
Next. This class has a slot correctLineAngle(int angle), in which I'd like to change a line's angle:
void TwoDotsGraphicsScene::correctLineAngle(int angle)
{
if(secondPoint == NULL)
return;
qDebug() << "agnle " << angle;
perpLine->line().setAngle(angle);
qDebug() << "lineAngle " << perpLine->line().angle();
calculateDistance();
}
void TwoDotsGraphicsScene::correctLineAngle(int angle)
{
if(secondPoint == NULL)
return;
qDebug() << "agnle " << angle;
perpLine->line().setAngle(angle);
qDebug() << "lineAngle " << perpLine->line().angle();
calculateDistance();
}
To copy to clipboard, switch view to plain text mode
But debug output is kind of like:
lineAngle 93.7022
agnle 121
lineAngle 93.7022
agnle 127
lineAngle 93.7022
agnle 133
lineAngle 93.7022
agnle 136
lineAngle 93.7022
So, I guess setAngle not having an effect. What should I do?
Bookmarks