Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt - Creating smooth rounded corners of a widget

Tags:

widget

qt

I have tried creating a smooth rounded corners of a widget using method described below:

  1. Create a widget with Qt::Window | Qt::FramelessWindowHint and Qt::WA_TranslucentBackground flag;
  2. Create a QFrame inside of a widget;
  3. Set a stylesheel to QFrame, for example:
border: 1px solid red;
border-radius: 20px;
background-color: black;

I was able to attain the smooth rounded corners but the widget is "window" type so i am not able to position the widget according to other widgets. Can we attain the complete transparency of a widget by not making the widget as "window" type?

like image 210
parveen arora Avatar asked Aug 25 '14 07:08

parveen arora


People also ask

How do I round widgets?

We can make button widget as complete circular shape(Android& iOS). Set border as 1 and select style as 'complete rounded corner', provided you have given equal height and width to the widget.

Why use rounded corners UI?

Rounded Corners Make Information Easier to ProcessSharp corners throw your eyes off the path of the line so you end up experiencing abrupt pauses when the line changes direction. But with rounded corners, the line leads your eyes around each corner to continue along the path smoothly.

What is round corner and smooth corner?

Corner radius rounds the corner where two lines meet. Use this to create shapes with rounded corners. Corner smoothing adjusts a rounded corner to create a continuous curve.


1 Answers

Your question is quite unclear. It sounds to me like this is a widget you want to add to a layout. If you want a widget with rounded corners, just use a QFrame and set a style-sheet to it:

myFrame->setStyleSheet(".QFrame{background-color: red; border: 1px solid black; border-radius: 10px;}");

There is no need to create a widget that contains a QFrame. Just use QFrame directly.

like image 69
thuga Avatar answered Sep 22 '22 11:09

thuga