@@ -135,16 +135,13 QChartView::RubberBands QChartView::rubberBand() const | |||||
135 | */ |
|
135 | */ | |
136 | void QChartView::mousePressEvent(QMouseEvent *event) |
|
136 | void QChartView::mousePressEvent(QMouseEvent *event) | |
137 | { |
|
137 | { | |
138 | if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) { |
|
|||
139 |
|
||||
140 |
|
|
138 | QRectF plotArea = d_ptr->m_chart->plotArea(); | |
141 |
|
139 | if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() | ||
142 |
|
|
140 | && event->button() == Qt::LeftButton && plotArea.contains(event->pos())) { | |
143 |
|
|
141 | d_ptr->m_rubberBandOrigin = event->pos(); | |
144 |
|
|
142 | d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize())); | |
145 |
|
|
143 | d_ptr->m_rubberBand->show(); | |
146 |
|
|
144 | event->accept(); | |
147 | } |
|
|||
148 | } else { |
|
145 | } else { | |
149 | QGraphicsView::mousePressEvent(event); |
|
146 | QGraphicsView::mousePressEvent(event); | |
150 | } |
|
147 | } | |
@@ -181,8 +178,8 void QChartView::mouseMoveEvent(QMouseEvent *event) | |||||
181 | */ |
|
178 | */ | |
182 | void QChartView::mouseReleaseEvent(QMouseEvent *event) |
|
179 | void QChartView::mouseReleaseEvent(QMouseEvent *event) | |
183 | { |
|
180 | { | |
184 | if (d_ptr->m_rubberBand) { |
|
181 | if (d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) { | |
185 |
if (event->button() == Qt::LeftButton |
|
182 | if (event->button() == Qt::LeftButton) { | |
186 | d_ptr->m_rubberBand->hide(); |
|
183 | d_ptr->m_rubberBand->hide(); | |
187 | QRectF rect = d_ptr->m_rubberBand->geometry(); |
|
184 | QRectF rect = d_ptr->m_rubberBand->geometry(); | |
188 | // Since plotArea uses QRectF and rubberband uses QRect, we can't just blindly use |
|
185 | // Since plotArea uses QRectF and rubberband uses QRect, we can't just blindly use |
General Comments 0
You need to be logged in to leave comments.
Login now