Reputation: 14615
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));
painter->setPen(pen);
painter->setBrush(QBrush(Qt::SolidPattern));
painter->drawRect(someRect);
Upvotes: 8
Views: 3672
Reputation: 7330
You can use the following to get an invisible QPen :
painter->setPen(QPen(Qt::NoPen));
The default QPen constructor creates a black solid line pen with 1 width, you have to force the style to Qt::NoPen to get an invisible one.
Upvotes: 4
Reputation: 21250
You can simply set no pen, i.e.:
painter->setPen(Qt::NoPen);
In this case it will not draw a border line at all.
Upvotes: 12