I've written a function that must draw a filled up black circle on my graphicsscene. The function draws a black lined circle but not filled up? This is my function:
void World::damage(int x, int y)
{
QPainter painter(&worldImage);
painter.setBrush(QBrush(Qt::black));
painter.drawArc(x,y,150,50,0,16*360);
item = new QGraphicsPixmapItem(QPixmap::fromImage(worldImage));
this->addItem(item);
}
kind regards,
To draw a circle, take a compass with a pencil attached and place the ends on a piece of paper. Then, keeping the end without the pencil stationery, rotate the compass 360 degrees so the pencil draws a perfect circle. If you don't have a compass, you can draw a circle using a piece of string instead.
drawArc()
does not use a fill color, use drawEllipse()
for a full circle that is filled.
drawEllipse()
alone didnt solved my problem
just I added painter.setBrush(Qt::red);
before drawEllipse()
and works perfect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With