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

Stylesheet qlineargradient rendering is incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.15.2, 6.5.0 Beta1
    • GUI: Painting
    • None
    • Linux/X11

    Description

      This testcase: gradients.cpp shows that

      background-color: qlineargradient(...)

      does not render the gradient correctly. Compare with the QPainter code, which renders the gradient as expected:

      The problem comes from QGradient::ObjectBoundingMode (which is what src/gui/text/qcssparser.cpp uses), since the issue can actually be reproduced by changing the QPainter code to say

      QLinearGradient gradient(0.50, 1, 0.58, 0);
      gradient.setCoordinateMode(QGradient::ObjectBoundingMode); 

      Note that using ObjectMode (given that ObjectBoundingMode is actually deprecated) makes no difference (which makes sense given that there's no transform applied to the painter).

      From the documentation I assume this mode simply means "please multiply with the width and height of the object, respectively", but looking at QPainterPrivate::drawStretchedGradient and stretchGradientToUserSpace() in qpainter.cpp, it seems more complicated than that...

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            dfaure_kdab David Faure
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes