【问题标题】:QCandlestickSeries::hovered signal is not being emittedQCandlestickSeries::hovered 信号未发出
【发布时间】:2023-04-09 11:56:01
【问题描述】:

QObject::connect 返回 true,当我手动发出信号时,会在插槽中命中断点,但是当我将鼠标悬停在 QCandlestickSet 上时,不会发出信号。

我从图表中删除了所有其他自定义绘图,以确保没有任何东西覆盖烛台,但信号仍然没有触发。

“chartView”属于“ChartView”类型,它派生自“QChartView”。

“系列”的类型为“QCandlestickSeries”。

连接:

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

插槽:

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);'
}

提前谢谢你。

编辑:

当我单击蜡烛时,不会发出信号,但当我双击蜡烛时,会发出信号,并触发断点。

【问题讨论】:

    标签: c++ qt qchart


    【解决方案1】:

    所以我发现了问题。我重写了 mouseMoveEvent 来绘制我的十字准线,但我忘记调用父类的 mouseMoveEvent。

    旧定义:

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

    新定义:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-02
      • 2020-04-12
      • 2022-01-02
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多