You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 rivejä
555 B

  1. #include "connection.h"
  2. #include <QPen>
  3. Connection::Connection(Item* from, Item::AnchorType fromType,
  4. Item* to, Item::AnchorType toType, QGraphicsItem* parent)
  5. : QGraphicsLineItem(parent),
  6. from_(from), to_(to), fromType_(fromType), toType_(toType)
  7. {
  8. setZValue(-1); // 在图元之下
  9. setPen(QPen(Qt::black, 2));
  10. from_->addConnection(this);
  11. to_->addConnection(this);
  12. updatePosition();
  13. }
  14. void Connection::updatePosition()
  15. {
  16. setLine(QLineF(from_->anchorPos(fromType_), to_->anchorPos(toType_)));
  17. }