@@ -70,18 +70,13 void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q | |||
|
70 | 70 | |
|
71 | 71 | void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event) |
|
72 | 72 | { |
|
73 | if (m_rect.contains(event->pos())) { | |
|
74 | m_clickOffset = event->pos(); | |
|
75 | event->setAccepted(true); | |
|
76 | } else { | |
|
77 | event->setAccepted(false); | |
|
78 | } | |
|
73 | event->setAccepted(true); | |
|
79 | 74 | } |
|
80 | 75 | |
|
81 | 76 | void Callout::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
82 | 77 | { |
|
83 | 78 | if (event->buttons() & Qt::LeftButton){ |
|
84 |
setPos(mapToParent(event->pos() - |
|
|
79 | setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton))); | |
|
85 | 80 | event->setAccepted(true); |
|
86 | 81 | } else { |
|
87 | 82 | event->setAccepted(false); |
@@ -94,7 +89,7 void Callout::setText(const QString &text) | |||
|
94 | 89 | QFontMetrics metrics(m_font); |
|
95 | 90 | m_textRect = metrics.boundingRect(QRect(0, 0, 150, 150), Qt::AlignLeft, m_text); |
|
96 | 91 | m_textRect.translate(5, 5); |
|
97 |
prepareGeometryChange(); |
|
|
92 | prepareGeometryChange(); | |
|
98 | 93 | m_rect = m_textRect.adjusted(-5, -5, 5, 5); |
|
99 | 94 | } |
|
100 | 95 |
General Comments 0
You need to be logged in to leave comments.
Login now