Qt 6.11 is out! See what's new in the release
blog
LineChart: one line with different colors
-
I found a kind of solution to do this using gradients. It is probably not the best way but by now it accomplishes the goal.
QLinearGradient gradient(0,0,0,1); gradient.setColorAt(0, Qt::blue); gradient.setColorAt(threshold_low-0.1, Qt::blue); gradient.setColorAt(threshold_low, Qt::gray); gradient.setColorAt(threshold_up, Qt::gray); gradient.setColorAt(threshold_up+0.1, Qt::red); gradient.setColorAt(1, Qt::red); gradient.setCoordinateMode(QGradient::StretchToDeviceMode); QPen pen(QBrush(gradient), 2);
