0

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)));
user7431005
  • 3,899
  • 4
  • 22
  • 49

1 Answers1

1

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.

Benjamin T
  • 8,120
  • 20
  • 37
  • I call `QChartView::mousePressEvent(event);` in my `void ChartView::mousePressEvent(QMouseEvent *event)` function... – user7431005 Oct 31 '17 at 12:25
  • @user7431005 Ok. Can you provide more details and more samples of your code like your class definitions and implementations of interesting functions like `mousePressEvent()`? – Benjamin T Oct 31 '17 at 12:31
  • it is the same as in [this](https://doc.qt.io/qt-5/qtcharts-zoomlinechart-example.html) example, class ChartView – user7431005 Oct 31 '17 at 14:18
  • @user7431005 Have you tried running the example ? If the example works and not your code then you need to show your code (or a minimal working example that reproduce the error) if you want people to help you. If the example does not work, then it is not your code. – Benjamin T Oct 31 '17 at 14:22