简体   繁体   中英

qt QScatterSeries clicked signal is emitted to ChartView mousePressEvent

I have a custom implementation of QChartView where I can zoom. (Class " ChartView " from this example) In there I have a mousePressEvent .

Now I wanted to add a QScatterSeries and connect the clicked signal with a custom slot. Unfortunately as soon as I click on my QScatterSeries only a signal is emitted to my ChartView mousePressEvent slot and not to my QScatterSeries mypoint_clicked slot.

I also added an QScatterSeries hovered signal which works fine.

connect(myScatterSeries, SIGNAL(hovered(QPointF,bool)), this, SLOT(mypoint_hovered(QPointF,bool)));
connect(myScatterSeries, SIGNAL(clicked(QPointF)), this, SLOT(mypoint_clicked(QPointF)));

Just guessing here.

mousePressEvent() is not a slot, but an event handler. I guess that QChartView::mousePressEvent() is somewhat responsible for handling mouse press events on the chart and dispatching them to series.

If you reimplemented ChartView::mousePressEvent() without explicitly calling QChartView::mousePressEvent() to forward the event, you might prevent the normal event processing to dispatch the event to the series. And therefore QScatterSeries::clicked() is never emitted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM