Transparent Rounded Corner of Widgets
For customized widgets (derived from QWidget, QDialog, for example), we may want to set border radius and make rounded corner transparent. We can achieve this, by:
- Override
paintEvent(...)
, add Qt style sheet support to customized widgets. - Set translucent attribute by:
setAttribute(Qt::WA_TranslucentBackground);
. Maybe we also need to setQt::FramelessWindowHint
window flags for dialogs. - Set border radius of the widget, using
border-radius
style sheet.
Then, we get a round-corner widget.