diff --git a/sources/qetgraphicsitem/independenttextitem.cpp b/sources/qetgraphicsitem/independenttextitem.cpp index 208906463..8e5d03ef4 100644 --- a/sources/qetgraphicsitem/independenttextitem.cpp +++ b/sources/qetgraphicsitem/independenttextitem.cpp @@ -130,6 +130,8 @@ void IndependentTextItem::setTextWidth(qreal width) { if (!qIsFinite(width) || width <= 0) width = -1; + if (qFuzzyCompare(width, m_text_width)) + return; qreal document_width = width; //The automatic width of a text with centred or right-aligned diff --git a/sources/qetgraphicsitem/independenttextitem.h b/sources/qetgraphicsitem/independenttextitem.h index 3ff526c5d..571c9eeea 100644 --- a/sources/qetgraphicsitem/independenttextitem.h +++ b/sources/qetgraphicsitem/independenttextitem.h @@ -53,6 +53,11 @@ class IndependentTextItem : public DiagramTextItem void setUuid(const QUuid &uuid) {m_uuid = uuid; emit uuidChanged();} void newUuid() {setUuid(QUuid::createUuid());} //create new uuid for this item + //Hide QGraphicsTextItem::textWidth()/setTextWidth(), which are not + //virtual: called through a QGraphicsTextItem or DiagramTextItem + //pointer they would change the document only, and the width would + //be neither saved nor shown in the properties. Use these, or the + //"textWidth" property. qreal textWidth() const {return m_text_width;} void setTextWidth(qreal width); diff --git a/tests/qttest/fixtures/free_text_width.qet b/tests/qttest/fixtures/free_text_width.qet index f2f9f019b..cd6eb53ee 100644 --- a/tests/qttest/fixtures/free_text_width.qet +++ b/tests/qttest/fixtures/free_text_width.qet @@ -3,8 +3,7 @@ 10/2/26 02-10-2026 2026-10-02 - skeleton - /tmp/qet-mcp-new-k41dmnyo/skeleton.qet + free_text_width 18:39