Qt QWidget绘制圆角注意事项
作者:互联网
1、产生黑边
painter.setPen(Qt::NoPen); // 不设置画笔即可
2、背景不透明
this->setAttribute(Qt::WA_TranslucentBackground, true);
3、大致代码
this->setAttribute(Qt::WA_TranslucentBackground, true);
void widget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.setPen(Qt::NoPen);
painter.drawRoundedRect(this->rect(), 20, 20);
}
标签:圆角,NoPen,20,Qt,WA,QWidget,setPen,painter 来源: https://www.cnblogs.com/GEEK-ZHAO/p/16627327.html