我正在尝试使用QImage绘制透明图像,但是每次它都提供黑色背景。我有一个图像背景,我想在该背景上绘制一个透明的圆圈(无背景)。该怎么做?
我已经使用了这段代码
QImage image(size, QImage::Format_ARGB32);
image.fill(qRgba(0,0,0,0));
// Pick an arbitrary size for the circle
const int centerX = size.width() / 2;
const int centerY = size.height() / 2;
const int radius = std::min(centerX, centerY) * 2 / 3;
const int diameter = radius * 2;
// Draw the circle!
QPainter painter(&image);
painter.setPen(Qt::yellow);
painter.drawEllipse(centerX-radius, centerY-radius, diameter, diameter);
Run Code Online (Sandbox Code Playgroud)