Line 7: item->line() returns a temporary copy of the item's internal QLineF object. You modify that temporary object and then it is discarded.
Line 8: Prints the content of another (unchanged) copy of the line.
// To set both line ends
qDebug() << item->line();
// To move one end of the line
item->setLine(line);
qDebug() << item->line();
// To set both line ends
QGraphicsLineItem* item = new QGraphicsLineItem;
item->setLine(QLineF(QPointF(10, 10), QPointF(20, 20)));
qDebug() << item->line();
// To move one end of the line
QLineF line = item->line();
line.setP1(QPointF(30, 30));
item->setLine(line);
qDebug() << item->line();
To copy to clipboard, switch view to plain text mode
Bookmarks