QGradient::setColorAt warning spam in drawRaised()

Author: Xon77Created Sep 23, 2026Updated Sep 23, 2026
Labelsbug

Hello,

This message was written with the help of AI to solve an issue, where creating a gui generates errors in the post window. I do not know if it the best way to solve it. But with this fix, there is no longer error messages in the post window.

Environment

  • SuperCollider version: Latest Dev
  • Operating system: MacOS 27
  • Other details (Qt version, audio driver, etc.): Qt 6.8 & 6.11.2

Steps to reproduce

8 thin sliders, watch the Post Window spam:

supercollider
(
var w = Window.new("QGradient repro", Rect(100, 100, 220, 120)).front;
8.do { |i|
    // height 2px < the 3px threshold in drawRaised()
    Slider(w, Rect(10, 10 + (i * 12), 200, 2));
};
w.refresh;
)
ERROR: QGradient::setColorAt: Color position must be specified in the range 0 to 1
QGradient::setColorAt: Color position must be specified in the range 0 to 1

Problem

File: QtCollider/style/routines.hpp

cpp
double pos = shape._rect.height();
pos = (pos - 3) / pos;
lgrad.setColorAt(pos, color.darker(105));

pos isn't clamped to [0,1]. Any raised-style widget (Slider, Button, Knob, Slider2D, RangeSlider, Graph — all call drawRaised()) under 3px tall pushes it out of range, and Qt warns on every repaint instead of clamping internally.

Possible Fix

File to modify: QtCollider/style/routines.hpp Function: drawRaised(), line 120 (right after pos is computed) Change: add one new line. Nothing else in the function changes.

diff
     double pos = shape._rect.height();
     pos = (pos - 3) / pos;
+    pos = qBound(0.0, pos, 1.0);
 
     QLinearGradient lgrad(shape._rect.topLeft(), shape._rect.bottomLeft());

Source: supercollider/supercollider