Qt - Creating smooth rounded widget corners

I tried to create smooth rounded corners of the widget using the method described below:

  • Create a widget with Qt::Window | Qt::FramelessWindowHint Qt::Window | Qt::FramelessWindowHint and Qt::WA_TranslucentBackground flag;
  • Create a QFrame inside the widget;
  • Set the style for the QFrame , for example:
 border: 1px solid red; border-radius: 20px; background-color: black; 

I managed to achieve smooth rounded corners, but the widget was β€œwindowed,” so I cannot position the widget according to other widgets. Can we achieve full transparency of the widget without making the window type widget?

+5
source share
2 answers

Your question is not entirely clear. It seems to me that this is the widget that you want to add to the layout. If you need a rounded widget, just use a QFrame and set the style for it:

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

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

+8
source

If I understand your question correctly, you can use the QGraphicsOpacityEffect class for any windowless widget.

0
source

Source: https://habr.com/ru/post/1201052/


All Articles