No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

22 líneas
602 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. setFlags(QGraphicsItem::ItemIsSelectable);
  11. from_->addConnection(this);
  12. to_->addConnection(this);
  13. updatePosition();
  14. }
  15. void Connection::updatePosition()
  16. {
  17. setLine(QLineF(from_->anchorPos(fromType_), to_->anchorPos(toType_)));
  18. }