You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <QObject>
|
|
#include <QGraphicsTextItem>
|
|
#include <QGraphicsSceneMouseEvent>
|
|
#include <QBrush>
|
|
#include <QDebug>
|
|
#include <QPen>
|
|
#include <QPainter>
|
|
#include <cmath>
|
|
#include "global.h"
|
|
#include "GlobalDefine.h"
|
|
|
|
class MyQGraphicsTextItem : public QGraphicsTextItem
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum TransformType {
|
|
NONE,
|
|
MOVE,
|
|
ROTATE,
|
|
SCALE
|
|
};
|
|
public:
|
|
MyQGraphicsTextItem(const QString &text, QGraphicsItem *parent = nullptr)
|
|
: QGraphicsTextItem(text, parent) {
|
|
// 在这里可以设置文本的样式或者进行其他初始化操作
|
|
}
|
|
~MyQGraphicsTextItem();
|
|
|
|
signals:
|
|
void signal_select(int id);
|
|
|
|
public:
|
|
void SetTextAttr(double x1, double y1);
|
|
|
|
protected:
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
|
private:
|
|
QLineF m_levelLine;
|
|
TransformType m_translteType;
|
|
QPointF m_mousePressDownPos; //鼠标按下时在场景中的位置
|
|
|
|
public:
|
|
int m_id;
|
|
double charPosX = 0.0;
|
|
double charPosY = 0.0;
|
|
double charWidth = 0.0;
|
|
double charHeight = 0.0;
|
|
QString charContent;
|
|
};
|