How to change color in QPainter::CompositionMode_DestinationIn?
Unsolved
General and Desktop
-
Hi,
I have someWidget class ( inherits QWidget ) and paintEvent() on it.
void someWidget::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing); painter.setPen(Qt::NoPen); painter.fillRect(0, 0, width(), height(), Qt::white); int radius = 100; painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); QRadialGradient radialGrad(QPoint(200,200), radius); radialGrad.setColorAt(0, QColor(255, 0, 0, 0)); radialGrad.setColorAt(1, QColor(255, 0, 0, 255)); painter.setBrush(radialGrad); painter.drawEllipse(QPoint(200,200), radius, radius); }
And I would like to have red ellipse. Now I have black ellipse.
I tried to set:
radialGrad.setColorAt(0, QColor(255, 0, 0, 0)); radialGrad.setColorAt(1, QColor(255, 0, 0, 255));
To other colors: blue, green, but result is the same - black ellipse. So how can I get the red one?
EDIT:
Even simpler code:void someWidget::paintEvent(QPaintEvent *) { QPainter painter(this); painter.setRenderHints(QPainter::Antialiasing); painter.setPen(Qt::NoPen); painter.fillRect(0, 0, width(), height(), Qt::white); int radius = 100; painter.setCompositionMode(QPainter::CompositionMode_DestinationIn); painter.setBrush(QColor(255,0,0,200)); painter.drawEllipse(QPoint(200,200), radius, radius); }