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.

51 lines
1.1 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(this->boundingRect());*/
}
void MyQGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
m_textItemIsSelect = !m_textItemIsSelect;
if (m_textItemIsSelect)
{
setDefaultTextColor(CUR_SELECT_DIE);
}
else
{
setDefaultTextColor(RECT_COLOR);
}
if (event->button() == Qt::LeftButton)
{
emit signal_select(m_id);
}
}