Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Unsolved ChartView RubberBand zoom out (right click) event

    General and Desktop
    1
    1
    268
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cpper
      cpper last edited by cpper

      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:
          chartView.setMouseTracking(true);
          chartView.setInteractive(true);
          
          chartView.installEventFilter(this);
       
        //..................
      
        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.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post