From fda709c0e233a3c349ec4f221cbcaf4d5c6c7a51 Mon Sep 17 00:00:00 2001 From: jessequ Date: Fri, 31 Jul 2026 14:29:17 +0800 Subject: [PATCH] feat: add ptposition property to tect item --- include/graphicsItem/graphicsTextItem.h | 7 ++++--- source/graphicsItem/graphicsTextItem.cpp | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/graphicsItem/graphicsTextItem.h b/include/graphicsItem/graphicsTextItem.h index 284f344..bced226 100644 --- a/include/graphicsItem/graphicsTextItem.h +++ b/include/graphicsItem/graphicsTextItem.h @@ -13,7 +13,8 @@ class GraphicsTextItem : public AbstractShapeType, { Q_OBJECT Q_PROPERTY(QString text READ toPlainText WRITE setPlainText) - Q_PROPERTY(QFont itemFont READ itemFont WRITE setItemFont) + Q_PROPERTY(QPointF ptPosition READ pos WRITE setPos FINAL) + Q_PROPERTY(QFont textFont READ textFont WRITE setTextFont) Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor) Q_PROPERTY(QColor backgroundColor READ brushColor WRITE setBrushColor) @@ -41,8 +42,8 @@ public: void syncRotationDataFromParent(const double &) override; // Font property accessors - QFont itemFont() const { return font(); } - void setItemFont(const QFont &f) { setFont(f); updateSizeFromText(); } + QFont textFont() const { return font(); } + void setTextFont(const QFont &f) { setFont(f); updateSizeFromText(); } // Text color accessor (foreground) QColor textColor() const { return defaultTextColor(); } diff --git a/source/graphicsItem/graphicsTextItem.cpp b/source/graphicsItem/graphicsTextItem.cpp index 3b70d64..291094f 100644 --- a/source/graphicsItem/graphicsTextItem.cpp +++ b/source/graphicsItem/graphicsTextItem.cpp @@ -65,7 +65,8 @@ QString GraphicsTextItem::getPropertyGroup(const QString &propertyName) const { QList properties = { QStringLiteral("text"), - QStringLiteral("itemFont"), + QStringLiteral("ptPosition"), + QStringLiteral("textFont"), QStringLiteral("textColor"), QStringLiteral("backgroundColor") };