wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
PortHoverLabel.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QFont>
11#include <QGraphicsObject>
12#include <QPainterPath>
13
29class PortHoverLabel : public QGraphicsObject
30{
31public:
33 enum class Side { Left, Right, Top, Bottom };
34
35 enum { Type = QGraphicsItem::UserType + 4 };
36 int type() const override { return Type; }
37
44 explicit PortHoverLabel(const QString &text, Side side, QGraphicsItem *parent = nullptr);
45
47 QString text() const { return m_text; }
48
50 QRectF boundingRect() const override;
52 QPainterPath shape() const override;
54 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
55
56private:
57 QString m_text;
58 QRectF m_bounds;
59 QFont m_font;
60};
QString text() const
Returns the label text (the connected port's name).
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
PortHoverLabel(const QString &text, Side side, QGraphicsItem *parent=nullptr)
Constructs a label chip showing text, anchored at the item's origin (the port).
QPainterPath shape() const override
int type() const override
QRectF boundingRect() const override
Side
Which side of the port the chip is biased towards, away from the element body.