Thalia Thalia - 6 months ago 33
C++ Question

How can I draw with pen width of 0 (invisible not cosmetic)?

I want to draw shapes with a border of various widths.

If I set width = 0 though, I expect (imagine) that here will be no border... yet I read that the border 0 is very thin ("cosmetic") border.

How can I draw my shapes with invisible border ?

int penWidth = 0; // some user input, 0 to 20 maybe
QPen pen = QPen(Qt::red, penWidth, Qt::PenStyle(Qt::SolidLine));


You can simply set no pen, i.e.:


In this case it will not draw a border line at all.