22 : QGraphicsObject(parent)
27 m_font = QToolTip::font();
29 const QFontMetricsF metrics(m_font);
30 const qreal width = metrics.horizontalAdvance(m_text) + (2.0 * kPaddingX);
31 const qreal height = metrics.height() + (2.0 * kPaddingY);
37 m_bounds = QRectF(-(kPortGap + width), -height / 2.0, width, height);
40 m_bounds = QRectF(kPortGap, -height / 2.0, width, height);
43 m_bounds = QRectF(-width / 2.0, -(kPortGap + height), width, height);
46 m_bounds = QRectF(-width / 2.0, kPortGap, width, height);
51 setFlag(QGraphicsItem::ItemIgnoresTransformations,
true);
52 setZValue(kHoverLabelZ);
53 setAcceptedMouseButtons(Qt::NoButton);
77 painter->setPen(QPen(attributes.m_portHoverLabelText, 1.0));
78 painter->setBrush(attributes.m_portHoverLabelBg);
79 painter->drawRect(m_bounds);
81 painter->setFont(m_font);
82 painter->setPen(attributes.m_portHoverLabelText);
83 painter->drawText(m_bounds, Qt::AlignCenter, m_text);
PortHoverLabel(const QString &text, Side side, QGraphicsItem *parent=nullptr)
Constructs a label chip showing text, anchored at the item's origin (the port).