From 9882a79a9322c3ade7668200b2bf3586aa4d7eb4 Mon Sep 17 00:00:00 2001 From: Beat Hangartner Date: Wed, 7 Oct 2026 01:51:00 +0200 Subject: [PATCH] Refresh the free text handles when the text comes back to a folio itemChange() removed the corner handles when the text left the scene but did not bring them back when it returned still selected, which Qt allows (undoing a scripted delete does it) without a selection change. Refresh on every scene change. The two handle helpers are protected: nothing outside the class calls them. Co-Authored-By: Claude Fable 5.1 --- sources/qetgraphicsitem/diagramtextitem.cpp | 10 ++++++---- sources/qetgraphicsitem/diagramtextitem.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sources/qetgraphicsitem/diagramtextitem.cpp b/sources/qetgraphicsitem/diagramtextitem.cpp index 01e4829d9..08fdfafb8 100644 --- a/sources/qetgraphicsitem/diagramtextitem.cpp +++ b/sources/qetgraphicsitem/diagramtextitem.cpp @@ -365,17 +365,19 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *event) /** @brief DiagramTextItem::itemChange - Show or hide the resize handles with the selection. + Show or hide the resize handles with the selection and the scene. @param change @param value @return */ QVariant DiagramTextItem::itemChange(GraphicsItemChange change, const QVariant &value) { - if (change == QGraphicsItem::ItemSelectedHasChanged) + //Also when the text comes back to a scene: Qt keeps it selected + //across removeItem()/addItem() (undoing a delete) and sends no + //selection change, and its handles were removed with the scene. + if (change == QGraphicsItem::ItemSelectedHasChanged + || change == QGraphicsItem::ItemSceneHasChanged) refreshTextResizeHandles(); - else if (change == QGraphicsItem::ItemSceneHasChanged && !scene()) - removeTextResizeHandles(); return QGraphicsTextItem::itemChange(change, value); } diff --git a/sources/qetgraphicsitem/diagramtextitem.h b/sources/qetgraphicsitem/diagramtextitem.h index e43f1f1de..3a5d5ca4d 100644 --- a/sources/qetgraphicsitem/diagramtextitem.h +++ b/sources/qetgraphicsitem/diagramtextitem.h @@ -91,10 +91,10 @@ class DiagramTextItem : public QGraphicsTextItem void setPlainText(const QString &text); bool isHtml() const; + protected: void refreshTextResizeHandles(); TextResizeHandles *textResizeHandles() const {return m_resize_handles;} - protected: void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override;