##// END OF EJS Templates
Remove click exploding and hover highlighting from pie series API. User should always implement their own.
Remove click exploding and hover highlighting from pie series API. User should always implement their own.

File last commit:

r226:538ea0469912
r436:b334955b5e36
Show More
chartwidget.cpp
63 lines | 1.3 KiB | text/x-c | CppLexer
#include "chartwidget.h"
#include <QMouseEvent>
ChartWidget::ChartWidget(QWidget *parent)
: QChartView(parent),
m_rubberBand(QRubberBand::Rectangle,this)
{
}
void ChartWidget::mousePressEvent(QMouseEvent *event)
{
if(event->button()!=Qt::LeftButton) return;
int margin = this->margin();
QRect rect(margin,margin,width()-2*margin,height()-2*margin);
m_origin = event->pos();
if (!rect.contains(m_origin)) return;
m_rubberBand.setGeometry(QRect(m_origin, QSize()));
m_rubberBand.show();
event->accept();
}
void ChartWidget::mouseMoveEvent(QMouseEvent *event)
{
if(m_rubberBand.isVisible())
m_rubberBand.setGeometry(QRect(m_origin, event->pos()).normalized());
}
void ChartWidget::mouseReleaseEvent(QMouseEvent *event)
{
if( event->button()==Qt::LeftButton && m_rubberBand.isVisible()) {
m_rubberBand.hide();
QRect rect = m_rubberBand.geometry();
zoomIn(rect);
event->accept();
}
if(event->button()==Qt::RightButton) {
zoomOut();
}
}
void ChartWidget::keyPressEvent(QKeyEvent *event)
{
switch (event->key()) {
case Qt::Key_Plus:
zoomIn();
break;
case Qt::Key_Minus:
zoomOut();
break;
default:
QGraphicsView::keyPressEvent(event);
break;
}
}