Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Color Gradient for QBrush customization (Qwt Plot Background)
Forum Update on Monday, May 27th 2025

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vezprog
    wrote on 21 Mar 2012, 17:17 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on 21 Mar 2012, 17:24 last edited by
      #2

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

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vezprog
        wrote on 21 Mar 2012, 17:26 last edited by
        #3

        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.

        Thanks!

        1 Reply Last reply
        0

        1/3

        21 Mar 2012, 17:17

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved