Index: src/backend/worksheet/plots/cartesian/CartesianPlot.h =================================================================== --- src/backend/worksheet/plots/cartesian/CartesianPlot.h +++ src/backend/worksheet/plots/cartesian/CartesianPlot.h @@ -250,6 +250,7 @@ void updateLegend(); void childAdded(const AbstractAspect*); void childRemoved(const AbstractAspect* parent, const AbstractAspect* before, const AbstractAspect* child); + void childHovered(); void xDataChanged(); void yDataChanged(); Index: src/backend/worksheet/plots/cartesian/CartesianPlot.cpp =================================================================== --- src/backend/worksheet/plots/cartesian/CartesianPlot.cpp +++ src/backend/worksheet/plots/cartesian/CartesianPlot.cpp @@ -1396,6 +1396,12 @@ updateLegend(); } + // if an element is hovered, the curves which are handled manually in this class + // must be unhovered + const WorksheetElement* element = dynamic_cast(child); + if (element) + connect(element, &WorksheetElement::hovered, + this, &CartesianPlot::childHovered); } if (!isLoading()) { @@ -1464,6 +1470,25 @@ } } +/*! + * \brief CartesianPlot::childHovered + * Unhover all curves, when another child is hovered. The hover handling for the curves is done in its parent (CartesianPlot), + * because the hover should set when the curve is hovered and not just the bounding rect (for more see hoverMoveEvent) + */ +void CartesianPlot::childHovered() { + Q_D(CartesianPlot); + bool curveSender = dynamic_cast(QObject::sender()) != nullptr; + if (!d->isSelected()) { + if (d->m_hovered) + d->m_hovered = false; + d->update(); + } + if (!curveSender) { + for (auto curve: children()) + curve->setHover(false); + } +} + void CartesianPlot::updateLegend() { if (m_legend) m_legend->retransform(); @@ -2690,6 +2715,8 @@ update(); } else if (mouseMode == CartesianPlot::MouseMode::SelectionMode) { // hover the nearest curve to the mousepointer + // hovering curves is implemented in the parent, because no ignoreEvent() exist + // for it. Checking all curves and hover the first bool curve_hovered = false; QVector curves = q->children(); for (int i=curves.count() - 1; i >= 0; i--){ // because the last curve is above the other curves