PDA

View Full Version : wet floor problem



ugluk
20th February 2012, 14:26
Why doesn't this code work? I'd like to create the wet floor effect with Qt and I am painting on a QWidget.



painter.save();

reflectionGradient.setColorAt(.0f, QColor(0, 0, 0, 0));
reflectionGradient.setColorAt(1.0f, QColor(0, 0, 0, 255));

reflectionGradient.setFinalStop(0, pixmap.height());

painter.setCompositionMode(QPainter::CompositionMo de_DestinationIn);

painter.fillRect(pixmap.rect(), reflectionGradient);

painter.setCompositionMode(QPainter::CompositionMo de_DestinationOver);

painter.drawPixmap(zero, pixmap);

painter.restore();


Added after 16 minutes:

I think I have the answer:

int QPaintDevice::depth () const

returns 24, hence no destination alpha. Is it possible to force destination alpha to 32 somehow, or work around this limitation, without creating a temporary QPixmap or QImage.