@@ -200,7 +200,23 void QChartView::mouseReleaseEvent(QMouseEvent *event) | |||||
200 | } |
|
200 | } | |
201 |
|
201 | |||
202 | if (event->button() == Qt::RightButton) { |
|
202 | if (event->button() == Qt::RightButton) { | |
203 | d_ptr->m_chart->zoomOut(); |
|
203 | // If vertical or horizontal rubberband mode, restrict zoom out to specified axis. | |
|
204 | // Since there is no suitable API for that, use zoomIn with rect bigger than the | |||
|
205 | // plot area. | |||
|
206 | if (d_ptr->m_rubberBandFlags == VerticalRubberBand | |||
|
207 | || d_ptr->m_rubberBandFlags == HorizonalRubberBand) { | |||
|
208 | QRectF rect = d_ptr->m_chart->plotArea(); | |||
|
209 | if (d_ptr->m_rubberBandFlags == VerticalRubberBand) { | |||
|
210 | qreal adjustment = rect.height() / 2; | |||
|
211 | rect.adjust(0, -adjustment, 0, adjustment); | |||
|
212 | } else if (d_ptr->m_rubberBandFlags == HorizonalRubberBand) { | |||
|
213 | qreal adjustment = rect.width() / 2; | |||
|
214 | rect.adjust(-adjustment, 0, adjustment, 0); | |||
|
215 | } | |||
|
216 | d_ptr->m_chart->zoomIn(rect); | |||
|
217 | } else { | |||
|
218 | d_ptr->m_chart->zoomOut(); | |||
|
219 | } | |||
204 | event->accept(); |
|
220 | event->accept(); | |
205 | } |
|
221 | } | |
206 | } else { |
|
222 | } else { |
General Comments 0
You need to be logged in to leave comments.
Login now