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.

46 lines
1.2 KiB
C++

#include "MyQGraphicsTextItem.h"
MyQGraphicsTextItem::~MyQGraphicsTextItem()
{
}
void MyQGraphicsTextItem::SetTextAttr(double x1, double y1)
{
//设置当前线位置
setPos(QPointF(x1, y1));
//设置ID
m_id = GlobalDefine::GetInstance()->GetItemId();
//设置水平线
m_levelLine.setP1(QPointF(x1, y1));
m_levelLine.setP2(QPointF(x1 + 100, y1));
m_translteType = NONE;
//QFont font = this->font(); // 获取当前字体
//font.setPointSize(40); // 设置字体大小为24
//this->setFont(font); // 应用新字体
}
void MyQGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsTextItem::paint(painter, option, widget);
QPen pen;
pen.setWidth(FEATURE_POINT_LINE_WIDTH);
pen.setColor(RECT_COLOR);
painter->setPen(pen);
//painter->drawRect(QPointF(this->boundingRect().x(), this->boundingRect().y()), this->boundingRect().width(),this->boundingRect().height());
painter->drawRect(this->boundingRect());
//painter->drawRect(QRectF(this->boundingRect().x(), this->boundingRect().y(), this->boundingRect().width() / 2, this->boundingRect().height() / 2));
}
void MyQGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
emit signal_select(m_id);
}
}