##// END OF EJS Templates
Callout example: removed unnecessary variable
Marek Rosa -
r2379:9645dba0fec9
parent child
Show More
@@ -70,18 +70,13 void Callout::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
70
70
71 void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event)
71 void Callout::mousePressEvent(QGraphicsSceneMouseEvent *event)
72 {
72 {
73 if (m_rect.contains(event->pos())) {
74 m_clickOffset = event->pos();
75 event->setAccepted(true);
73 event->setAccepted(true);
76 } else {
77 event->setAccepted(false);
78 }
79 }
74 }
80
75
81 void Callout::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
76 void Callout::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
82 {
77 {
83 if (event->buttons() & Qt::LeftButton){
78 if (event->buttons() & Qt::LeftButton){
84 setPos(mapToParent(event->pos() - m_clickOffset));
79 setPos(mapToParent(event->pos() - event->buttonDownPos(Qt::LeftButton)));
85 event->setAccepted(true);
80 event->setAccepted(true);
86 } else {
81 } else {
87 event->setAccepted(false);
82 event->setAccepted(false);
@@ -27,7 +27,6 private:
27 QRectF m_rect;
27 QRectF m_rect;
28 QPointF m_anchor;
28 QPointF m_anchor;
29 QFont m_font;
29 QFont m_font;
30 QPointF m_clickOffset;
31 };
30 };
32
31
33 #endif // CALLOUT_H
32 #endif // CALLOUT_H
General Comments 0
You need to be logged in to leave comments. Login now