[SOLVED] Color Gradient for QBrush customization (Qwt Plot Background)

  • So what I am trying to accomplish right now is making a Color Gradient for a QwtPlot canvas background color through code because the colors are going to change dynamically.

    So for example: The plot scale for the x axis goes from 0 - 2000
    red background from 0 - 500
    yellow background from 501 - 750
    green background from 750 - 1250
    yellow background from 751 - 1500
    red background from 1501 - 2000

    The only way I can think of doing this would be to use a custom QBush using a gradient that does the above. I would like to be able to set the limits of each color though... I looked at the spectrogram example and found some cool color meshing techniques but unfortunately they are unavailable using a straight QwtPlot.

    i.e. function
    setCanvasBackground(const QBrush &);

    Any ideas?

  • Moderators

    Have you looked at "QLinearGradient?":http://qt-project.org/doc/qt-4.8/qlineargradient.html

  • exactly what i was looking for, even lets you do multiple colors! and unfortunately google was of no help with pointing me to this gold mine.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.