Results 1 to 2 of 2

Thread: QLinearGradient Coloring

  1. #1
    Join Date
    Jun 2012
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default QLinearGradient Coloring

    Greetings,

    I am wondering if it is possible to use a QGradient and assign it a custom color range.

    Let me explain : I am building an histogram with Qwt, and I wish to have the columns of that histogram to follow a specific set of colors.

    Example: When the user selects a cold color range, the histogram is displayed using the following method : The leftmost column starts in black and goes slowly towards blue, the middle column goes from blue to pink and the rightmost column goes from pink to white.

    My question is, if I use QLinearGradient and give it stops increments of 0.25 with black, blue, pink, white as the stop colors, can I make it follow the colors I give it or is it always going to use the chromatic circle's gradient to put between the stops?

    Thank you,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLinearGradient Coloring

    It is going to use whatever the internal implementation is (maybe that's the chromatic circle, I don't know) to interpolate between stops. If you want some other interpolation scheme, you need to either write your own QGradient class. And since it looks like QGradient has no public methods for retrieving the color for a specific location, QBrush must have privileged access to QGradient (friend status) so you'll have to look into the QBrush and QGradient source code to find out in detail how to implement your own gradient class.

  3. The following user says thank you to d_stranz for this useful post:

    WSQtProgrammer (6th July 2012)

Similar Threads

  1. Coloring Circle
    By Jeneo W. in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2010, 05:39
  2. Problem with row coloring in qtableview
    By Tiansen in forum Qt Programming
    Replies: 1
    Last Post: 24th May 2010, 19:13
  3. Regarding qlineargradient
    By jjbabu in forum Qt Programming
    Replies: 6
    Last Post: 15th April 2009, 10:21
  4. Coloring a QTableview column
    By Potch in forum Qt Programming
    Replies: 2
    Last Post: 5th April 2009, 00:18
  5. Coloring of Radio Button
    By jogeshwarakundi in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 22nd July 2008, 16:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.