Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

draw a filled up circle

Tags:

qt

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,

like image 560
user1007522 Avatar asked Mar 01 '12 13:03

user1007522


People also ask

How can I draw a circle?

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.


2 Answers

drawArc() does not use a fill color, use drawEllipse() for a full circle that is filled.

like image 128
Arnold Spence Avatar answered Oct 16 '22 23:10

Arnold Spence


drawEllipse() alone didnt solved my problem

just I added painter.setBrush(Qt::red);

before drawEllipse()

and works perfect.

like image 14
amt Avatar answered Oct 16 '22 22:10

amt