| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "GraphicsTextItem.h"
- #include <QDebug>
- GraphicsTextItem::GraphicsTextItem(QGraphicsItem *parent)
- : QGraphicsTextItem(parent)
- {
- setFlag(QGraphicsItem::ItemIsMovable);
- setFlag(QGraphicsItem::ItemIsSelectable);
- setFlag(QGraphicsItem::ItemIsFocusable );
- setFlag(QGraphicsItem::ItemAcceptsInputMethod);
- }
- //! [0]
- //! [1]
- QVariant GraphicsTextItem::itemChange(GraphicsItemChange change,
- const QVariant &value)
- {
- if (change == QGraphicsItem::ItemSelectedHasChanged)
- emit selectedChange(this);
- return value;
- }
- //! [1]
- //! [2]
- void GraphicsTextItem::focusOutEvent(QFocusEvent *event)
- {
- setTextInteractionFlags(Qt::NoTextInteraction);
- // emit lostFocus(this);
- QGraphicsTextItem::focusOutEvent(event);
- }
- //! [2]
- //! [5]
- void GraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
- {
- if (textInteractionFlags() == Qt::NoTextInteraction)
- setTextInteractionFlags(Qt::TextEditorInteraction);
- QGraphicsTextItem::mouseDoubleClickEvent(event);
- }
|