m_size
(QSize(DEFAULT_WIDTH, DEFAULT_HEIGHT
)){
setPos(p);
setAcceptHoverEvents(true);
setAcceptDrops(true);
}
QRectF QSampleItem
::boundingRect() const {
m_size.width() + RESIZE_HANDLE_WIDTH,
m_size.height() + RESIZE_HANDLE_HEIGHT);
}
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->drawRoundedRect(RESIZE_HANDLE_WIDTH/2,
RESIZE_HANDLE_HEIGHT/2,
m_size.width(),
m_size.height(),
5, 5);
}
QSampleItem::QSampleItem(QPointF p, QGraphicsItem *parent)
: QGraphicsItem(parent),
m_size(QSize(DEFAULT_WIDTH, DEFAULT_HEIGHT))
{
setPos(p);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setFlag(QGraphicsItem::ItemIsMovable, true);
setAcceptHoverEvents(true);
setAcceptDrops(true);
}
QRectF QSampleItem::boundingRect() const
{
return QRectF(0, 0,
m_size.width() + RESIZE_HANDLE_WIDTH,
m_size.height() + RESIZE_HANDLE_HEIGHT);
}
void QSampleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
painter->drawRoundedRect(RESIZE_HANDLE_WIDTH/2,
RESIZE_HANDLE_HEIGHT/2,
m_size.width(),
m_size.height(),
5, 5);
}
To copy to clipboard, switch view to plain text mode
{
qDebug()<<"Inside mousePressEvent";
m_mousePressPoint = event->scenePos().toPoint();
}
{
qDebug()<<"Inside mouseMoveEvent";
}
{
m_mousePressPoint
= QPoint(-1,
-1);
}
void QSampleItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
qDebug()<<"Inside mousePressEvent";
m_mousePressPoint = event->scenePos().toPoint();
QGraphicsItem::mousePressEvent(event);
}
void QSampleItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
qDebug()<<"Inside mouseMoveEvent";
QGraphicsItem::mouseMoveEvent(event);
}
void QSampleItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
m_mousePressPoint = QPoint(-1, -1);
QGraphicsItem::mouseReleaseEvent(event);
}
To copy to clipboard, switch view to plain text mode
Bookmarks