12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #include "CRectItem.h"
- #include <QDebug>
- CRectItem::CRectItem(QGraphicsItem *parent) : CRectItem(QRectF(), parent) { }
- CRectItem::CRectItem(const QRectF &rect, QGraphicsItem *parent) : CPathItem(parent), m_rect(rect)
- {
- updatePath();
- }
- QRectF CRectItem::rect() const
- {
- return m_rect;
- }
- void CRectItem::setRect(const QRectF &rect)
- {
- m_rect = rect;
- }
- int CRectItem::cornerRadius() const
- {
- return m_cornerRadius;
- }
- void CRectItem::setCornerRadius(qreal radius)
- {
- m_cornerRadius = radius;
- updatePath();
- }
- void CRectItem::updatePath()
- {
- QPainterPath path;
- path.addRoundedRect(m_rect, m_cornerRadius, m_cornerRadius);
- setPath(path);
- }
- void CRectItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
- {
- qDebug() << __FUNCTION__ << __LINE__ << event << endl;
- }
|