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;