Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

21 righe
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. }