Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-3793

QGradient does not allow two color stops with same position

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • P3: Somewhat important
    • 5.0.0
    • 4.5.0
    • GUI: Painting
    • None

    Description

      I added some color stops by using the QGradient::setStops() function like this
      QGradientStops stops;
      stops.append( QGradientStop(0.0, QColor(Qt::red)));
      stops.append( QGradientStop(0.5, QColor(Qt::green)));
      stops.append( QGradientStop(0.5, QColor(Qt::black)));
      stops.append( QGradientStop(1.0, QColor(Qt::blue)));
      QLinearGradient g;
      g.setStops( stops );

      I expected to get a gradient with four color stops.

      Instead I got a gradient with three color stops, where the third color stop just replaced the second one.

      I think a gradient with the color stops like shown above is perfectly valid as it allows some quick color changes within a gradient on a single position (from one color to another). As the setStops function apparently uses the setColorAt function, only unique color stop positions are possible. That is rather bad if you develop a way to let the user move the color stops with the mouse. Once the user crosses one color stop with another, one of them is deleted when adding them to a QGradient.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sletta Gunnar Sletta
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes