Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a circle QLabel?

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.

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

Thanks.

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

like image 925
Evans Belloeil Avatar asked May 21 '14 14:05

Evans Belloeil


2 Answers

I tried to use stylesheet by setting border-radius and min-width/min-height. It looks like

QLabel{
  border-radius: 10px;
  min-height: 20px;
  min-width: 20px;
}
like image 94
Joey Avatar answered Nov 12 '22 16:11

Joey


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

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

like image 45
TheDarkKnight Avatar answered Nov 12 '22 16:11

TheDarkKnight