feat: add ptposition property to tect item

This commit is contained in:
jessequ 2026-07-31 14:29:17 +08:00
parent 2e93156093
commit fda709c0e2
2 changed files with 6 additions and 4 deletions

View File

@ -13,7 +13,8 @@ class GraphicsTextItem : public AbstractShapeType<QGraphicsTextItem>,
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString text READ toPlainText WRITE setPlainText) 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 textColor READ textColor WRITE setTextColor)
Q_PROPERTY(QColor backgroundColor READ brushColor WRITE setBrushColor) Q_PROPERTY(QColor backgroundColor READ brushColor WRITE setBrushColor)
@ -41,8 +42,8 @@ public:
void syncRotationDataFromParent(const double &) override; void syncRotationDataFromParent(const double &) override;
// Font property accessors // Font property accessors
QFont itemFont() const { return font(); } QFont textFont() const { return font(); }
void setItemFont(const QFont &f) { setFont(f); updateSizeFromText(); } void setTextFont(const QFont &f) { setFont(f); updateSizeFromText(); }
// Text color accessor (foreground) // Text color accessor (foreground)
QColor textColor() const { return defaultTextColor(); } QColor textColor() const { return defaultTextColor(); }

View File

@ -65,7 +65,8 @@ QString GraphicsTextItem::getPropertyGroup(const QString &propertyName) const
{ {
QList<QString> properties = { QList<QString> properties = {
QStringLiteral("text"), QStringLiteral("text"),
QStringLiteral("itemFont"), QStringLiteral("ptPosition"),
QStringLiteral("textFont"),
QStringLiteral("textColor"), QStringLiteral("textColor"),
QStringLiteral("backgroundColor") QStringLiteral("backgroundColor")
}; };