Important: Please read the Qt Code of Conduct -

ChartView RubberBand zoom out (right click) event

  • Hello,
    I want to control the zoom out event caused by right clicking when rubber band is enabled in a chart view. I want to achieve this, but using eventFilter instead of subclassing QChartView. However, the mouse release event seems not to be triggered. Here is the code:

        //MainWindow constructor:
      bool MainWindow::eventFilter(QObject *watched, QEvent *event){ 
          if(watched == &chartView && event->type() == QEvent::MouseButtonRelease){
               if(static_cast<QMouseEvent*>(event)->button() == Qt::RightButton)  {
                   qDebug() << "here i am" ;              
           return QMainWindow::eventFilter(watched, event);

    If I replace QEvent::MouseButtonRelease with QEvent::MouseButtonPress the event gets called. However the zooming out happens when releasing the mouse, so that is what I need to control.

Log in to reply