Home > Enterprise >  QCandlestickSeries::hovered signal is not being emitted
QCandlestickSeries::hovered signal is not being emitted

Time:12-07

The QObject::connect returns true and when I manually emit the signal, the breakpoint is hit in the slot, but when I hover over a QCandlestickSet, the signal is not emitted.

I removed all other custom drawings from the chart to be sure nothing was overlaying the candlesticks, but the signal still does not fire.

'chartView' is of type 'ChartView' which is derived from 'QChartView'.

'series' is of type 'QCandlestickSeries'.

Connection:

QObject::connect(this->series, SIGNAL(hovered(bool, QCandlestickSet *)), this->chartView, SLOT(displayCandleValues(bool, QCandlestickSet *)));

Slot:

void ChartView::displayCandleValues(bool status, QCandlestickSet *candle)
{
    qint32 x = 0; // A breakpoint is set on this line and is triggered when calling 'emit this->series->hovered(false, Q_NULLPTR);'
}

Candlestick Chart

Thank you in advance.

Edit:

When I single click on the on a candle the signal is NOT emitted, but when I double click on a candle the signal IS emitted, and the breakpoint is triggered.

CodePudding user response:

So I found the issue. I had overridden the mouseMoveEvent to draw my crosshair and I forgot to call the parent class' mouseMoveEvent.

Old definition:

void ChartView::mouseMoveEvent(QMouseEvent *event)
{
    this->drawCrosshair(event->pos());
}

New definition:

void ChartView::mouseMoveEvent(QMouseEvent *event)
{
    this->drawCrosshair(event->pos());
    QChartView::mouseMoveEvent(event);
}
  • Related