1 Star 3 Fork 2

loong/BackupConfigure

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
rectitem.cpp 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
loong 提交于 2021-03-25 18:06 . Initial commit
#include "rectitem.h"
#include <QPainter>
RectItem::RectItem(QGraphicsItem *parent)
:BaseItem(parent)
{
}
RectItem::RectItem(const QRectF &rect,QGraphicsItem *parent)
:BaseItem(parent)
{
setRect(rect);
}
RectItem::RectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent)
:BaseItem(parent)
{
setRect(QRectF(x, y, w, h));
}
RectItem::~RectItem()
{
}
QRectF RectItem::boundingRect() const
{
if (myBoundingRect.isNull())
{
qreal halfpw;
if(pen().widthF() > 5)
halfpw = pen().widthF() / 2;
else
halfpw = (pen().widthF() + BaseItem::resizeHandleWidth) / 2 ;
myBoundingRect = BaseItem::rect();
if (halfpw > 0.0)
myBoundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
}
return myBoundingRect;
}
QPainterPath RectItem::shape() const
{
QPainterPath path;
path.addRect(myRect);
return qt_graphicsItem_shapeFromPath(path, this->pen());
}
void RectItem::paintShape(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(widget);
painter->setPen(pen());
painter->setBrush(brush());
painter->drawRect(myRect);
}
int RectItem::type() const
{
return Type;
}
QDataStream &operator >>(QDataStream &in, RectItem &rectItem)
{
qint32 itemType;
QRectF rect;
QPointF pos;
QPen pen;
QBrush brush;
in >> itemType >> rect >> pos >> pen >> brush;
rectItem.setRect(rect);
rectItem.setPen(pen);
rectItem.setBrush(brush);
rectItem.setPos(pos);
return in;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/kingofloong/BackupConfigure.git
git@gitee.com:kingofloong/BackupConfigure.git
kingofloong
BackupConfigure
BackupConfigure
master

搜索帮助