jiapei100
7th March 2013, 22:26
Hi, all:
My code is as simple as:
QPointF end1 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p1();
QPointF end2 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p2();
std::cout << end1.x() << " " << end1.y() << std::endl;
std::cout << end2.x() << " " << end2.y() << std::endl;
dynamic_cast<QGraphicsLineItem*>(lineItem)->moveBy(dx, dy); // I'm pretty sure dx and dy are not 0
end1 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p1();
end2 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p2();
std::cout << end1.x() << " " << end1.y() << std::endl;
std::cout << end2.x() << " " << end2.y() << std::endl;
two outputs of end1/end2 are always the same. However, I'm expecting there should be some difference, right?
Why moveBy() doesn't really move two end points of such a QGraphicsLineItem ?
How can I successfully move the end points then?
cheers
Pei
My code is as simple as:
QPointF end1 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p1();
QPointF end2 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p2();
std::cout << end1.x() << " " << end1.y() << std::endl;
std::cout << end2.x() << " " << end2.y() << std::endl;
dynamic_cast<QGraphicsLineItem*>(lineItem)->moveBy(dx, dy); // I'm pretty sure dx and dy are not 0
end1 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p1();
end2 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p2();
std::cout << end1.x() << " " << end1.y() << std::endl;
std::cout << end2.x() << " " << end2.y() << std::endl;
two outputs of end1/end2 are always the same. However, I'm expecting there should be some difference, right?
Why moveBy() doesn't really move two end points of such a QGraphicsLineItem ?
How can I successfully move the end points then?
cheers
Pei