如何制作QLabel圆圈? [英] How do I make a circle QLabel?

查看:226
本文介绍了如何制作QLabel圆圈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个QLabel,我用样式表填充了红色,但QLabel是矩形的,我想要一个圆.我尝试添加边框半径,但这没有用,可能是因为我将QLabel放在了formLayout中.

I have a QLabel that i fill in red with the stylesheet, but the QLabel is rectangular, and I want a circle. I try to add border-radius, but it doesn't work, maybe because i put my QLabel in a formLayout.

有没有一种简单的方法可以通过使用样式表来获得圆形QLabel?

Is there a simple method to have a round QLabel by using stylesheet ?

谢谢.

使用图片似乎比现在更容易.

EDIT : Using a picture seems more easier than doing this now.

推荐答案

创建用作遮罩的图像,并通过调用setMask在标签上设置该图像. 正如文档所述:-

Create an image that you use as a mask and set that on the label by calling setMask. As the documentation states: -

仅导致其位图具有对应的1位可见的窗口小部件的像素.如果该区域包括小部件的rect()外部的像素,则取决于平台,该区域中的窗口系统控件可能可见,也可能不可见

Causes only the pixels of the widget for which bitmap has a corresponding 1 bit to be visible. If the region includes pixels outside the rect() of the widget, window system controls in that area may or may not be visible, depending on the platform

这篇关于如何制作QLabel圆圈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆