MistyD
MistyD

Reputation: 17223

How to create a circle like this using QPaint

I am trying to create something like this

enter image description here

This is my approach

QPixmap target(60,80);            
QBrush BackGroundBrush;
BackGroundBrush.setColor(QColor(Qt::GlobalColor::black));
QPainter painter(&target);
painter.setBackground(BackGroundBrush);
painter.drawEllipse(10,10,10,10);

Now I wanted to know how I could fill it completely with color ? I was then thinking of painting another circle(white) inside this circle?

Upvotes: 0

Views: 98

Answers (2)

MistyD
MistyD

Reputation: 17223

I solved this by doing the following

BackGroundBrush->setStyle(Qt::SolidPattern)

Upvotes: 0

Predelnik
Predelnik

Reputation: 5246

You have to use painter.setPen to choose what color and style you will be drawing boundaries with and painter.setBrush to set color and style of what you will be filling it with. Basically to fill something with solid color without boundaries you have to use simply:

painter.setPen (Qt::NoPen);
painter.setBrush (colorOfYourLiking);

About setBackground there's following lines in Qt documentation:

Sets the background brush of the painter to the given brush.

The background brush is the brush that is filled in when drawing opaque text, stippled lines and bitmaps.

I guess this is not what you need.

Upvotes: 2

Related Questions