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

QPainter: Setting clipping to false does not seem to have an effect on Mac OS X when using a gradient brush.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P3: Somewhat important
    • Some future release
    • 4.4.2
    • GUI: Painting
    • None
    • macOS

    Description

      Setting clipping to false does not seem to have an effect on Mac OS X when using a gradient brush.

      Can be reproduced with the following example:

      #include <QApplication>
      #include <QWidget>
      #include <QPainter>

      inline QColor qt_mix_colors(QColor a, QColor b)
      {
      return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
      (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
      }

      class RenderBug : public QWidget
      {
      public:
      RenderBug(QWidget *parent = 0) : QWidget( parent ) {}

      protected:
      void paintEvent(QPaintEvent *event)

      { QPainter painter(this); painter.setRenderHint( QPainter::Antialiasing, true ); QRect r1( 30, 30, 30, 30 ); QRect r2( 30, 60, 30, 30 ); painter.setPen( palette().dark().color() ); painter.setBrush( palette().light().color() ); #if 1 // enable this code to display the bug QLinearGradient gradient( r1.topLeft(), r2.bottomLeft()); gradient.setColorAt( 1., palette().dark().color() ); gradient.setColorAt( .13, qt_mix_colors( palette().dark().color(), palette().light().color() ) ); gradient.setColorAt( 0., palette().light().color() ); painter.setBrush( gradient ); #endif painter.drawRect( r1.adjusted( 5,5,-5,-5) ); painter.setClipRect( r1 ); painter.setClipping( true ); painter.drawLine( QLine(r1.bottomLeft(), r1.topRight()) ); painter.setClipping( false ); painter.drawRect( r2.adjusted( 5,5,-5,-5) ); }

      };

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);
      RenderBug widget;
      widget.setGeometry(100, 100, 500, 355);
      widget.show();
      return app.exec();
      }

      Attachments

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

        Activity

          People

            sletta Gunnar Sletta
            sanonymous Nokia Qt Support (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes