##// END OF EJS Templates
fix to example. Event handling prototyping.
sauimone -
r2169:04485231feed
parent child
Show More
@@ -70,7 +70,7 MainWidget::MainWidget(QWidget *parent) :
70
70
71 QPushButton *disConnectButton = new QPushButton("Disconnect markers");
71 QPushButton *disConnectButton = new QPushButton("Disconnect markers");
72 connect(disConnectButton, SIGNAL(clicked()), this, SLOT(disconnectMarkers()));
72 connect(disConnectButton, SIGNAL(clicked()), this, SLOT(disconnectMarkers()));
73 m_buttonLayout->addWidget(connectButton, 8, 0);
73 m_buttonLayout->addWidget(disConnectButton, 9, 0);
74
74
75
75
76 m_legendPosX = new QDoubleSpinBox();
76 m_legendPosX = new QDoubleSpinBox();
@@ -40,7 +40,7 LegendMarkerItem::LegendMarkerItem(QLegendMarkerPrivate *marker, QGraphicsObject
40 m_space(4)
40 m_space(4)
41 {
41 {
42 // qDebug() << "LegendMarkerItem created for marker:" << m_marker;
42 // qDebug() << "LegendMarkerItem created for marker:" << m_marker;
43 setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
43 // setAcceptedMouseButtons(Qt::LeftButton|Qt::RightButton);
44 m_rectItem->setRect(m_markerRect);
44 m_rectItem->setRect(m_markerRect);
45 // setZValue(zValue() + 20);
45 // setZValue(zValue() + 20);
46 // qDebug() << "z:" << this->zValue();
46 // qDebug() << "z:" << this->zValue();
@@ -168,7 +168,7 void LegendMarkerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
168 qDebug() << "LegendMarkerItem::mousePressEvent";
168 qDebug() << "LegendMarkerItem::mousePressEvent";
169 // QGraphicsObject::mousePressEvent(event);
169 // QGraphicsObject::mousePressEvent(event);
170 //TODO: selected signal removed for now
170 //TODO: selected signal removed for now
171 emit m_marker->handleMousePressEvent(event);
171 m_marker->handleMousePressEvent(event);
172 QGraphicsItem::mousePressEvent(event);
172 QGraphicsItem::mousePressEvent(event);
173 }
173 }
174
174
@@ -451,7 +451,7 QLegendPrivate::QLegendPrivate(ChartPresenter *presenter, QChart *chart, QLegend
451 m_attachedToChart(true),
451 m_attachedToChart(true),
452 m_backgroundVisible(false)
452 m_backgroundVisible(false)
453 {
453 {
454
454 m_items->setHandlesChildEvents(false);
455 }
455 }
456
456
457 QLegendPrivate::~QLegendPrivate()
457 QLegendPrivate::~QLegendPrivate()
@@ -23,6 +23,7
23 #include "legendmarkeritem_p.h"
23 #include "legendmarkeritem_p.h"
24 #include <QDebug>
24 #include <QDebug>
25 #include <QFontMetrics>
25 #include <QFontMetrics>
26 #include <QGraphicsSceneEvent>
26
27
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 /*
29 /*
@@ -116,8 +117,10 QLegendMarkerPrivate::~QLegendMarkerPrivate()
116
117
117 void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event)
118 void QLegendMarkerPrivate::handleMousePressEvent(QGraphicsSceneEvent *event)
118 {
119 {
119 // Just emit clicked signal for now
120 // Just emit clicked signal for now (our default logic for events)
120 Q_UNUSED(event);
121 // This could propably be on the LegendMarkerItem?
122 // TODO: how to handle scrolling vs clicking? drag event?
123 event->accept();
121 Q_Q(QLegendMarker);
124 Q_Q(QLegendMarker);
122 emit q->clicked();
125 emit q->clicked();
123 }
126 }
General Comments 0
You need to be logged in to leave comments. Login now