Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

33 řádky
959 B

  1. #include "comparator.h"
  2. #include <QPainter>
  3. #include <QStyleOptionGraphicsItem>
  4. Comparator::Comparator(const QString &type) : Item(type)
  5. {
  6. }
  7. void Comparator::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *)
  8. {
  9. painter->setRenderHint(QPainter::Antialiasing);
  10. if (type_ == "比较") {
  11. painter->drawRect(QRectF(-12, -8, 24, 16));
  12. painter->setFont(QFont("Arial", 8));
  13. painter->drawText(QRectF(-10, -8, 20, 16), Qt::AlignCenter, "CP");
  14. // 锚点
  15. painter->setBrush(Qt::darkGray);
  16. painter->setPen(Qt::NoPen);
  17. painter->drawEllipse(QPointF(-18, 0), 4, 4);
  18. painter->drawEllipse(QPointF(18, 0), 4, 4);
  19. }
  20. if (option->state & QStyle::State_Selected) {
  21. QPen pen(Qt::DashLine);
  22. pen.setColor(Qt::blue);
  23. pen.setWidth(2);
  24. painter->setPen(pen);
  25. painter->setBrush(Qt::NoBrush);
  26. painter->drawRect(boundingRect());
  27. }
  28. }