Qt 窗口控件添加圆角效果

优点:不会被覆盖

#define BORDER_RADIUS 4 //圆角
void paintEventHandle(QWidget *widget) {
	QBitmap bmp(widget->size());
	bmp.fill();

	QPainter p(&bmp);
	p.setRenderHint(QPainter::Antialiasing);
	p.setPen(Qt::NoPen);
	p.setBrush(Qt::black);
	p.drawRoundedRect(bmp.rect(), BORDER_RADIUS, BORDER_RADIUS);

	widget->setMask(bmp);
}

 

你可能感兴趣的:(Qt)