10

Code for the beginning:

QColor yellow("#f0d048");
Qt::BrushStyle style = Qt::SolidPattern;
QBrush brush(yellow, style);
painter.setBrush(brush);
painter.drawEllipse(10,10,10,10);

Everytime I do this, I get a yellow circle surrounded by a black 1-pixel-sized border. In total the circle will have the same size like if I draw with black colour, so what shall I do to just get a single-coloured yellow circle without black border?

Best regards

Thalia
  • 13,637
  • 22
  • 96
  • 190
Aragon
  • 183
  • 2
  • 8

1 Answers1

22

Set a pen on painter

painter.setPen(Qt::NoPen);

Qt has 'brush' for filling figures, and 'pen' for drawing lines and outlines.

Thalia
  • 13,637
  • 22
  • 96
  • 190
  • Thank you, I just now realized that basically every shape has an outline which seems to be black as standard, so the pen-setting can "overwrite" this to any colour (or nothing) – Aragon Jul 01 '15 at 07:33
  • In my case, setting pen to `Qt::NoPen` didn't solve the issue, but setting it to a transparent color (i.e. `QColor(0,0,0,0)`) did. Your emphasize on the distinction between Qt's notion of brushes and pens is very much appreciated. Thanks. – Tenders McChiken Mar 22 '21 at 05:56