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

WA_TranslucentBackground dont repaint on MacOSX

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 5.2.1
    • None
    • Qt 5.2.1, MacOSX 10.9.2
    • macOS

      Widget with WA_TranslucentBackground flag don't repaint background properly.

      I created test application that contains QWidegt with setAttribute( Qt::WA_TranslucentBackground, true); and QLabel as a child. QPropertyAnimation animates QLabel position from TopLeft corner of QWidget to bottomRight corner.

       
      TransWidget::TransWidget(QWidget *parent) :
          QWidget(parent),
          ui(new Ui::TransWidget)
      {
          ui->setupUi(this);
      
          resize( 400, 400);
          move( QPoint(100, 100));
      
          setWindowFlags( Qt::FramelessWindowHint);
          setAttribute( Qt::WA_TranslucentBackground, true);
          setAutoFillBackground( false);
      
          QLabel *l = new QLabel( this);
          l->setText( "Example text");
          l->setAutoFillBackground( false);
      
          QPropertyAnimation *a = new QPropertyAnimation(l, "geometry");
      
          a->setDuration( 10000);
          a->setStartValue( l->rect());
      
          QRect eRect;
          eRect = l->rect();
          eRect.moveTopLeft( this->rect().bottomRight());
          a->setEndValue( eRect);
      
          a->start();
      }

      Expected result (and achivable on i.e. Win8 with Qt 5.2.1)
      QLabel (with text "Example text" will animate from top left corner to bottom right corner of parent widget with translucent background) and on screen I got correct result on WIndows:

      And on MacOSX, with translucent background:

      and macOSX without translucent background:

      And what resolves that issue is setting in paintEvent:

       
          QPainter p( this );
       
          p.setCompositionMode( QPainter::CompositionMode_Clear );
          p.fillRect( this->rect(), Qt::transparent );
      

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

            peppe Giuseppe D'Angelo
            talei Talei
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes