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

Gradients drawn using ObjectBoundingMode render incorrectly when scrolled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 4.6.0
    • 4.5.0
    • GUI: Painting
    • None
    • 5c3c0d477104f6f4eafaceeacac8278c4b97f8cc

      VBoxLayout with multiple QLabels in a scrollarea some 'header' labels have a gradient background

      As the scrollarea is scrolled a few pixels at a time the gradient is drawn and scaled to fill the newly exposed clip-rect only.

      If the area is resized then the gradient is drawn correctly

      Expected to see:

      The same visual effect whether I scrolled down or expanded the window down (given no stretch)

      Assuming the widget has a gradient:

      1234567890

      If I position the widget to clip the right 25% to get

      1234567|

      If I scroll in such a way as to expose the right 25% of the widget, I expect the gradient colours from 0.75-1.0 to be used to fill the rightmost 25% of the widget and to get:

      01234567890

      Got instead:

      Clip-artefacts: the newly exposed area is filled using the full gradient
      If I position the widget to clip the right 25% I get

      1234567|

      If I now scroll in such a way as to expose the right 25% of the widget, I get the gradient colours from 0 - 1.0 used to fill the rightmost 25% of the widget. This means I get:

      01234567159

      To see:

      1 size the window large to see the entire widgets

      2 resize the window to clip the shaded widgets. The gradient is redrawn to the visible object.

      3 resize the window to clip the shaded widgets horizontally by 20%

      4 scroll by clicking in the 'trough', not by dragging the slider. The newly exposed rectangle has the complete gradient.

      5 drag scrolling produces unpleasant lines.

      Example program:

      #include <QApplication>
      #include <QScrollArea>
      #include <QLabel>
      #include <QVBoxLayout>
      #include <QPalette>
      #include <QLinearGradient>

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);

      QScrollArea sa;
      QWidget c;
      QVBoxLayout box(&c);

      QPalette pal = sa.palette();
      pal.setColor(QPalette::WindowText, QColor(255,255,255));
      QLinearGradient bgGrad = QLinearGradient(0,0,1,1);
      bgGrad.setCoordinateMode(QGradient::ObjectBoundingMode);
      // bgGrad.setCoordinateMode(QGradient::StretchToDeviceMode);
      bgGrad.setColorAt(0.0, QColor("red"));
      bgGrad.setColorAt(1.0, QColor("green"));
      pal.setBrush(QPalette::Window, bgGrad);

      QLabel *l;

      for(int i=0;++i<10

      { l = new QLabel("FrederickFrederickFrederickFrederickFrederickFrederickFrederick\nFrederickFrederickFrederickFrederickFrederick\nFrederickFrederickFrederickFrederickFrederickFrederickFrederickFrederick\nFrederickFrederickFrederickFrederick"); l->setAutoFillBackground(true); l->setPalette(pal); box.addWidget(l); box.addWidget(new QLabel("DavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavid\nDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavidDavid")); }

      sa.setWidget(&c);
      sa.show();
      return app.exec();
      }

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

            wallison Warwick Allison (closed Nokia identity) (Inactive)
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes