123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #ifndef CTEXTITEM_H
- #define CTEXTITEM_H
- #include <QGraphicsTextItem>
- class CTextItem : public QGraphicsTextItem
- {
- Q_OBJECT
- public:
- explicit CTextItem(QGraphicsItem *parent = nullptr);
- explicit CTextItem(const QString &text = QString(), QGraphicsItem *parent = nullptr);
- virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
- void keyPressEvent(QKeyEvent *event) override;
- void beginEditing();
- void endEditing();
- bool isEditing() const;
- bool allowEdit() const;
- void setAllowEdit(bool a);
- static QSizeF textSize(const QString t, qreal width = -1);
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
- public slots:
- void slotTextChanged();
- void slotTextChange(int from, int charsRemoved, int charsAdded);
- signals:
- void sigWillBeginEditing();
- void sigTextChanged();
- private:
- bool m_allowEdit = true;
- bool m_textChanged = false;
- };
- #endif // CTEXTITEM_H
|