Important: Please read the Qt Code of Conduct -


  • I want to use a Q(Linear)Gradient in a way that is similar to a colour chooser. But given a position there doesn't appear to be a way to extract the colour at that position which seems rather a shame.

    Is there any easy way to achieve this? If necessary I can try to locate the source repository and "borrow" the relevant code... Are there any protected methods I could use to achieve this that aren't in the documentation?

    This is a bit more complex than just finding the colour at one of the defined stops which is trivial. The control I'm working on would also allow you to double click between stops to add an extra stop, hence the wish to find the colour at a specific position.


  • Qt Champions 2019

  • I was thinking in terms of the QGradient position value (i.e. 0.0 to 1.0) rather than using some form of pixel under mouse technique as the rodent won't necessarily be in the gradient but may well be next to it where the markers are held (not 100% trivial to convert to a position where it would be over the gradient itself):



Log in to reply