feat: add node graphic item

This commit is contained in:
parker
2025-06-20 03:42:27 +01:00
parent 7394f72f51
commit cf876320d8
6 changed files with 57 additions and 11 deletions

View File

@@ -0,0 +1,29 @@
#pragma once
#include <QGraphicsItem>
#include <QPainter>
class NodeGraphic
: public QGraphicsItem
{
public:
NodeGraphic(QGraphicsItem *parent = nullptr);
QRectF boundingRect() const override
{
qreal penWidth = 6;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
20 + penWidth, 20 + penWidth);
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
{
QPen greenPen = QPen(Qt::green);
greenPen.setWidth(6);
painter->setPen(greenPen);
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
}
private:
QGraphicsTextItem* title_;
};