Array Visualizer: fix scatter markers losing their style

Scatter markers can be recreated by Qt Charts without inheriting the
series pen/brush, leaving nearly invisible 1 px markers. This occurs
reliably with large datasets while small ones usually render correctly.

Reapply the scatter series pen and brush after addSeries() by forcing
two actual style transitions. Since the setters are guarded, simply
reassigning the existing values is a no-op.

Verified on Qt 6.4.2 with both small (100 points) and large (4000
points) datasets. Line and spline series are unaffected.
This commit is contained in:
tiresiasfromthebai
2026-07-14 15:47:18 +02:00
parent 8d3db26b9f
commit f0f620c632
+26
View File
@@ -24,6 +24,30 @@
#include <QtCore/QDebug>
#include <QtGlobal>
//
// Qt Charts 6.x workaround: scatter marker items can be (re)created without
// inheriting the series' pen/brush, leaving near-invisible ~1px markers.
// Small arrays usually render fine; large ones (e.g. 4000 points) reliably
// degrade. The series-level state is correct in both cases (verified with an
// instrumented build), so the style is lost at the marker-item level inside
// Qt Charts. Because the series setters are guarded (a call with an unchanged
// value is a no-op), we force two *actual* value transitions so the style is
// pushed down to the marker items unconditionally.
//
static void redecorateScatterSeries (QXYSeries* series) {
QScatterSeries* scatter = qobject_cast<QScatterSeries*>(series);
if (scatter == nullptr) {
return;
}
scatter->setPen(QPen(Qt::transparent));
scatter->setBrush(QBrush(Qt::transparent));
scatter->setPen(QPen(Qt::NoPen));
scatter->setBrush(QBrush(QColor(31, 119, 180)));
}
SeerArrayVisualizerWidget::SeerArrayVisualizerWidget (QWidget* parent) : QWidget(parent) {
// Init variables.
@@ -983,6 +1007,7 @@ void SeerArrayVisualizerWidget::handleDataChanged () {
arrayChartView->chart()->addSeries(_aSeries);
arrayChartView->chart()->createDefaultAxes();
redecorateScatterSeries(_aSeries);
}
if (_bSeries) {
@@ -990,6 +1015,7 @@ void SeerArrayVisualizerWidget::handleDataChanged () {
arrayChartView->chart()->addSeries(_bSeries);
arrayChartView->chart()->createDefaultAxes();
redecorateScatterSeries(_bSeries);
}
// Zoom out slightly to allow for text label at edges.